+
✓ All Magento 2 categories have matching names in Magento 1.
@endif
@@ -2198,6 +2198,99 @@ function closeDeleteConfirmPopup() {
if (overlay) overlay.remove();
}
+ // Refresh M2 categories not in M1 table
+ function refreshM2CategoriesNotInM1() {
+ fetch('{{ route("migration.m2-categories-not-in-m1") }}', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN': '{{ csrf_token() }}'
+ }
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ const tbody = document.getElementById('m2-categories-not-in-m1-tbody');
+ const totalDiv = document.getElementById('m2-categories-not-in-m1-total');
+ const emptyDiv = document.getElementById('m2-categories-not-in-m1-empty');
+
+ if (!tbody) return;
+
+ // Clear existing rows
+ tbody.innerHTML = '';
+
+ if (data.categories && data.categories.length > 0) {
+ // Show table and total, hide empty message
+ const tableWrapper = document.getElementById('m2-categories-not-in-m1-table-wrapper');
+ if (tableWrapper) tableWrapper.style.display = 'block';
+ if (emptyDiv) emptyDiv.style.display = 'none';
+ if (totalDiv) {
+ totalDiv.style.display = 'block';
+ totalDiv.innerHTML = `
Total: ${data.count} ${data.count === 1 ? 'category' : 'categories'} found in Magento 2 but not in Magento 1.`;
+ }
+
+ // Add rows
+ data.categories.forEach(category => {
+ const row = document.createElement('tr');
+ row.style.borderBottom = '1px solid #dee2e6';
+
+ const statusClass = category.is_active ? 'active' : 'inactive';
+ const statusText = category.is_active ? 'Active' : 'Inactive';
+
+ let rootCategoryHtml = '';
+ if (category.root_category_name && category.root_category_name !== 'N/A') {
+ rootCategoryHtml = `
${category.root_category_name}`;
+ if (category.root_category_id) {
+ rootCategoryHtml += `
(ID: ${category.root_category_id})`;
+ }
+ } else {
+ rootCategoryHtml = '
N/A';
+ }
+
+ row.innerHTML = `
+
${category.entity_id} |
+
${category.name || 'Unnamed Category'} |
+
${category.level || 'N/A'} |
+
+ ${statusText}
+ |
+
${rootCategoryHtml} |
+
${category.path || 'N/A'} |
+ `;
+
+ tbody.appendChild(row);
+ });
+ } else {
+ // Hide table and total, show empty message
+ const tableWrapper = document.getElementById('m2-categories-not-in-m1-table-wrapper');
+ if (tableWrapper) tableWrapper.style.display = 'none';
+ if (totalDiv) totalDiv.style.display = 'none';
+ if (emptyDiv) {
+ emptyDiv.style.display = 'block';
+ } else {
+ // Create empty message if it doesn't exist
+ const section = tbody.closest('.section');
+ if (section) {
+ const newEmptyDiv = document.createElement('div');
+ newEmptyDiv.id = 'm2-categories-not-in-m1-empty';
+ newEmptyDiv.style.marginTop = '15px';
+ newEmptyDiv.style.padding = '15px';
+ newEmptyDiv.style.background = '#d4edda';
+ newEmptyDiv.style.borderLeft = '4px solid #28a745';
+ newEmptyDiv.style.borderRadius = '4px';
+ newEmptyDiv.style.color = '#155724';
+ newEmptyDiv.textContent = '✓ All Magento 2 categories have matching names in Magento 1.';
+ section.appendChild(newEmptyDiv);
+ }
+ }
+ }
+ }
+ })
+ .catch(error => {
+ console.error('Error refreshing M2 categories not in M1:', error);
+ });
+ }
+
// Delete category
function deleteCategory(categoryId, categoryName, source) {
const container = source === 'm1' ? document.getElementById('m1-tree-container') : document.getElementById('m2-tree-container');
@@ -2222,6 +2315,8 @@ function deleteCategory(categoryId, categoryName, source) {
loadM1Tree();
} else {
loadM2Tree();
+ // Refresh M2 categories not in M1 table after deleting from M2
+ refreshM2CategoriesNotInM1();
}
} else {
container.innerHTML = originalContent;
diff --git a/routes/web.php b/routes/web.php
index ac748f3..ecbc5a9 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -16,6 +16,7 @@
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::get('/m2-categories-not-in-m1', [MagentoMigrationController::class, 'getM2CategoriesNotInM1'])->name('migration.m2-categories-not-in-m1');
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');