From b8bd7e7eb78b73de8bae6ad47287ef39b1eba4ce Mon Sep 17 00:00:00 2001 From: O K Date: Thu, 25 Sep 2025 19:14:23 +0300 Subject: [PATCH] fix grouping --- controllers/front/productdatagenerate.php | 40 ++++++++++++----------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/controllers/front/productdatagenerate.php b/controllers/front/productdatagenerate.php index 3c1cfe8..b5e369b 100644 --- a/controllers/front/productdatagenerate.php +++ b/controllers/front/productdatagenerate.php @@ -69,25 +69,27 @@ class ProductLinkCheckerProductDataGenerateModuleFrontController extends ModuleF $combinations = $product->getAttributeCombinations($id_lang); if ($combinations) { foreach ($combinations as $combination) { - $all_product_data[$product->id . '_' . $combination['id_product_attribute']] = [ - 'id_product' => (int)$product->id, - 'id_product_attribute' => (int)$combination['id_product_attribute'], - 'meta_title' => $product->meta_title, // Meta is usually product-level - 'meta_description' => $product->meta_description, - // Title and descriptions are also from the main product - 'title' => $product->name, - 'description' => Tools::getValue('plc_no_description') ? null : $product->description, - 'description_short' => Tools::getValue('plc_no_description_short') ? null : $product->description_short, - // These fields are specific to the combination - 'mpn' => $combination['mpn'] ?? null, - 'reference' => $combination['reference'] ?? null, - 'ean13' => $combination['ean13'] ?? null, - 'upc' => $combination['upc'] ?? null, - 'id_language' => (int)$id_lang, - 'id_shop' => (int)$id_shop, - 'link' => $this->context->link->getProductLink($product, null, null, null, (int)$id_lang, (int)$id_shop, (int)$combination['id_product_attribute']), - 'link_rewrite' => $product->link_rewrite, - ]; + if (!isset($all_product_data[$product->id . '_' . $combination['id_product_attribute']])) { + $all_product_data[$product->id . '_' . $combination['id_product_attribute']] = [ + 'id_product' => (int)$product->id, + 'id_product_attribute' => (int)$combination['id_product_attribute'], + 'meta_title' => $product->meta_title, // Meta is usually product-level + 'meta_description' => $product->meta_description, + // Title and descriptions are also from the main product + 'title' => $product->name, + 'description' => Tools::getValue('plc_no_description') ? null : $product->description, + 'description_short' => Tools::getValue('plc_no_description_short') ? null : $product->description_short, + // These fields are specific to the combination + 'mpn' => $combination['mpn'] ?? null, + 'reference' => $combination['reference'] ?? null, + 'ean13' => $combination['ean13'] ?? null, + 'upc' => $combination['upc'] ?? null, + 'id_language' => (int)$id_lang, + 'id_shop' => (int)$id_shop, + 'link' => $this->context->link->getProductLink($product, null, null, null, (int)$id_lang, (int)$id_shop, (int)$combination['id_product_attribute']), + 'link_rewrite' => $product->link_rewrite, + ]; + } $all_product_data[$product->id . '_' . $combination['id_product_attribute']]['attributes'][] = [ 'group_name' => $combination['group_name'] ?? null, 'attribute_name' => $combination['attribute_name'] ?? null,