update delete box for categories
This commit is contained in:
parent
c5b8a0452d
commit
e14f280de1
|
|
@ -32,6 +32,10 @@ public function index()
|
|||
$m1AttributeGroups = $this->migrationService->getMagento1AttributeGroups();
|
||||
$m2AttributeGroups = $this->migrationService->getMagento2AttributeGroups();
|
||||
$m1AttributeGroupsMissingInM2 = $this->migrationService->getM1AttributeGroupsMissingInM2();
|
||||
$m1Products = $this->migrationService->getMagento1Products();
|
||||
$m2Products = $this->migrationService->getMagento2Products();
|
||||
$m1ProductsNotInM2 = $this->migrationService->getM1ProductsNotInM2();
|
||||
$m2ProductsNotInM1 = $this->migrationService->getM2ProductsNotInM1();
|
||||
|
||||
return view('migration.index', [
|
||||
'm1Stores' => $m1Stores,
|
||||
|
|
@ -46,6 +50,10 @@ public function index()
|
|||
'm1AttributeGroups' => $m1AttributeGroups,
|
||||
'm2AttributeGroups' => $m2AttributeGroups,
|
||||
'm1AttributeGroupsMissingInM2' => $m1AttributeGroupsMissingInM2,
|
||||
'm1Products' => $m1Products,
|
||||
'm2Products' => $m2Products,
|
||||
'm1ProductsNotInM2' => $m1ProductsNotInM2,
|
||||
'm2ProductsNotInM1' => $m2ProductsNotInM1,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -106,6 +114,50 @@ public function getMagento1CategoryTree()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Magento 1 category tree with products
|
||||
*/
|
||||
public function getMagento1CategoryTreeWithProducts()
|
||||
{
|
||||
try {
|
||||
$tree = $this->migrationService->getMagento1CategoryTreeWithProducts();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'tree' => $tree
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error fetching M1 category tree with products: ' . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Failed to load category tree with products: ' . $e->getMessage(),
|
||||
'tree' => []
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Magento 2 category tree with products
|
||||
*/
|
||||
public function getMagento2CategoryTreeWithProducts()
|
||||
{
|
||||
try {
|
||||
$tree = $this->migrationService->getMagento2CategoryTreeWithProducts();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'tree' => $tree
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error fetching M2 category tree with products: ' . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Failed to load category tree with products: ' . $e->getMessage(),
|
||||
'tree' => []
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Magento 2 category tree
|
||||
*/
|
||||
|
|
@ -220,6 +272,97 @@ public function migrateAttributeGroup(Request $request, $groupId, $setId)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate all products from Magento 1 to Magento 2
|
||||
*/
|
||||
public function migrateProducts(Request $request)
|
||||
{
|
||||
try {
|
||||
$dryRun = $request->input('dry_run', false);
|
||||
$result = $this->migrationService->migrateProducts($dryRun);
|
||||
|
||||
return response()->json($result, $result['success'] ? 200 : 400);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Product migration error: ' . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Migration failed: ' . $e->getMessage(),
|
||||
'added' => 0,
|
||||
'updated' => 0,
|
||||
'errors' => 0,
|
||||
'log' => [],
|
||||
'missing_attributes' => []
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a single product from Magento 2
|
||||
*/
|
||||
public function deleteM2Product(Request $request, $productId)
|
||||
{
|
||||
try {
|
||||
$result = $this->migrationService->deleteM2Product($productId);
|
||||
|
||||
return response()->json($result, $result['success'] ? 200 : 400);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Delete M2 product error: ' . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Deletion failed: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync product category assignments from M1 to M2
|
||||
*/
|
||||
public function syncProductCategories(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = $this->migrationService->syncProductCategories();
|
||||
|
||||
return response()->json($result, $result['success'] ? 200 : 400);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Sync product categories error: ' . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Sync failed: ' . $e->getMessage(),
|
||||
'updated' => 0,
|
||||
'skipped' => 0,
|
||||
'errors' => 0,
|
||||
'log' => []
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all products in Magento 2 that have entity_id greater than max M1 product ID
|
||||
*/
|
||||
public function deleteM2ProductsAboveM1Max(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = $this->migrationService->deleteM2ProductsAboveM1Max();
|
||||
|
||||
return response()->json($result, $result['success'] ? 200 : 400);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Delete M2 products error: ' . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Deletion failed: ' . $e->getMessage(),
|
||||
'deleted' => 0
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the migration
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -13,9 +13,15 @@
|
|||
Route::get('/test-connections', [MagentoMigrationController::class, 'testConnections'])->name('migration.test-connections');
|
||||
Route::get('/magento1-categories', [MagentoMigrationController::class, 'getMagento1Categories'])->name('migration.magento1-categories');
|
||||
Route::get('/magento1-category-tree', [MagentoMigrationController::class, 'getMagento1CategoryTree'])->name('migration.magento1-category-tree');
|
||||
Route::get('/magento1-category-tree-with-products', [MagentoMigrationController::class, 'getMagento1CategoryTreeWithProducts'])->name('migration.magento1-category-tree-with-products');
|
||||
Route::get('/magento2-category-tree', [MagentoMigrationController::class, 'getMagento2CategoryTree'])->name('migration.magento2-category-tree');
|
||||
Route::get('/magento2-category-tree-with-products', [MagentoMigrationController::class, 'getMagento2CategoryTreeWithProducts'])->name('migration.magento2-category-tree-with-products');
|
||||
Route::delete('/category/{categoryId}', [MagentoMigrationController::class, 'deleteCategory'])->name('migration.delete-category');
|
||||
Route::put('/category/{categoryId}/rename', [MagentoMigrationController::class, 'renameCategory'])->name('migration.rename-category');
|
||||
Route::post('/attribute/{attributeId}/migrate', [MagentoMigrationController::class, 'migrateAttribute'])->name('migration.migrate-attribute');
|
||||
Route::post('/attribute-group/{groupId}/{setId}/migrate', [MagentoMigrationController::class, 'migrateAttributeGroup'])->name('migration.migrate-attribute-group');
|
||||
Route::post('/products/migrate', [MagentoMigrationController::class, 'migrateProducts'])->name('migration.migrate-products');
|
||||
Route::post('/products/sync-categories', [MagentoMigrationController::class, 'syncProductCategories'])->name('migration.sync-product-categories');
|
||||
Route::delete('/products/{productId}', [MagentoMigrationController::class, 'deleteM2Product'])->name('migration.delete-product');
|
||||
Route::delete('/products/above-m1-max', [MagentoMigrationController::class, 'deleteM2ProductsAboveM1Max'])->name('migration.delete-products-above-m1-max');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue