тут очень много с карточкой товара и импортом.

This commit is contained in:
Alisa
2026-06-05 18:50:38 +03:00
parent be883c5843
commit c08519263c
8 changed files with 379 additions and 69 deletions
+23
View File
@@ -170,6 +170,28 @@ function execute_old_site_import_batch(string $sqlPath, string $progressPath, ar
];
}
function normalize_old_site_product_categories(PDO $pdo): void
{
$pdo->exec(
"UPDATE products p
SET p.category_id = (
SELECT pcl.category_id
FROM product_category_links pcl
INNER JOIN categories c ON c.id = pcl.category_id
WHERE pcl.product_id = p.id
AND c.is_active = 1
ORDER BY c.parent_id IS NULL, pcl.sort_order, pcl.category_id
LIMIT 1
)
WHERE p.legacy_path LIKE '/katalog/product/view/1/%'
AND EXISTS (
SELECT 1
FROM product_category_links pcl_exists
WHERE pcl_exists.product_id = p.id
)"
);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$action = (string) ($_POST['action'] ?? 'start');
@@ -186,6 +208,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$progress = execute_old_site_import_batch($sqlPath, $progressPath, $progress);
if (!empty($progress['done'])) {
normalize_old_site_product_categories(Database::pdo());
$message = 'Импорт выполнен. SQL-команд выполнено: ' . (int) $progress['executed'] . '.';
} else {
$message = 'Импорт продолжается: ' . (float) $progress['percent'] . '%, команд за этот шаг: ' . (int) $progress['batch_executed'] . '.';