diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index 9a1427a5..f3667fff 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -2541,9 +2541,9 @@ }, "import-product.php": { "type": "-", - "size": 32802, + "size": 147, "lmtime": 1748902490178, - "modified": false + "modified": true }, "index.php": { "type": "-", @@ -2590,7 +2590,28 @@ }, "localization": {}, "logs": {}, - "mails": {}, + "mails": { + "pl": { + "order_conf.html": { + "type": "-", + "size": 57460, + "lmtime": 1748904409867, + "modified": false + } + }, + "themes": { + "modern": { + "core": { + "order_conf.html.twig": { + "type": "-", + "size": 37681, + "lmtime": 1748904409868, + "modified": false + } + } + } + } + }, "Makefile": { "type": "-", "size": 88, @@ -7351,7 +7372,18 @@ "upgrade": {}, "views": {} }, - "leoproductsearch": {}, + "leoproductsearch": { + "views": { + "js": { + "leosearch.js": { + "type": "-", + "size": 5313, + "lmtime": 1748904409869, + "modified": false + } + } + } + }, "leoquicklogin": {}, "leoslideshow": {}, "medoo.php": { @@ -7398,7 +7430,18 @@ "ps_customersignin": {}, "ps_customtext": {}, "ps_dataprivacy": {}, - "ps_emailalerts": {}, + "ps_emailalerts": { + "mails": { + "pl": { + "new_order.html": { + "type": "-", + "size": 57408, + "lmtime": 1748904409871, + "modified": false + } + } + } + }, "ps_emailsubscription": { "composer.json": { "type": "-", @@ -8527,14 +8570,14 @@ }, "dr_materac.css": { "type": "-", - "size": 83952, - "lmtime": 1748716771022, + "size": 83967, + "lmtime": 1748904409873, "modified": false }, "dr_materac.css.map": { "type": "-", - "size": 31537, - "lmtime": 1748716771023, + "size": 31547, + "lmtime": 1748904409874, "modified": false }, "dr_materac.css.sync-conflict-20231027-200011-EDGUH2C.map": { @@ -8545,8 +8588,8 @@ }, "dr_materac.scss": { "type": "-", - "size": 100108, - "lmtime": 1748716771025, + "size": 100127, + "lmtime": 1748904409875, "modified": false }, "dr_materac.sync-conflict-20231027-195749-EDGUH2C.css": { @@ -12971,8 +13014,8 @@ }, "detail1526395446.tpl": { "type": "-", - "size": 30298, - "lmtime": 1743238532895, + "size": 30326, + "lmtime": 1748904409878, "modified": false }, "detail1526396195.tpl": { diff --git a/import-product.php b/import-product.php index 2c1f5492..c2222c1a 100644 --- a/import-product.php +++ b/import-product.php @@ -55,68 +55,36 @@ foreach ( $products_array as $product ) $price = 0; // jeśli są kombinacje, to cena jest 0 $reference = $product['ean']; - $id_tax_rules_group = 62; // ID grupy reguł podatkowych - $active = 1; // Ustawienie produktu jako nieaktywny - $sql = 'UPDATE `' . _DB_PREFIX_ . 'product` - SET `price` = ' . (float)$price . ', - `id_tax_rules_group` = ' . (int)$id_tax_rules_group . ', - `active` = ' . (int)$active . ' - WHERE `reference` = \'' . pSQL($reference) . '\''; - $result = Db::getInstance()->execute($sql); + $active = 0; // Ustawienie produktu jako nieaktywny - $result = Db::getInstance()->executeS('SELECT id_product FROM `' . _DB_PREFIX_ . 'product` WHERE `reference` = \'' . pSQL($reference) . '\''); - - // $id_product może być tablicą - if ( is_array( $result ) ) + // table `materac_product` + if ( $reference ) { - foreach ( $result as $id ) + $sql = 'UPDATE `' . _DB_PREFIX_ . 'product` SET `price` = ' . (float)$price . ', `active` = ' . (int)$active . ' WHERE `reference` = \'' . pSQL($reference) . '\''; + $result = Db::getInstance()->execute($sql); + // table `materac_product_shop` + $products_ids = Db::getInstance()->executeS('SELECT id_product FROM `' . _DB_PREFIX_ . 'product` WHERE `reference` = \'' . pSQL($reference) . '\''); + foreach ( $products_ids as $id ) { - // update materac_product_shop where id_product = id_product - $sql_shop = 'UPDATE `' . _DB_PREFIX_ . 'product_shop` - SET `price` = ' . (float)$price . ', - `id_tax_rules_group` = ' . (int)$id_tax_rules_group . ', - `active` = ' . (int)$active . ' - WHERE `id_product` = ' . $id['id_product']; + $sql_shop = 'UPDATE `' . _DB_PREFIX_ . 'product_shop` SET `price` = ' . (float)$price . ', `active` = ' . (int)$active . ' WHERE `id_product` = ' . (int)$id['id_product']; $result_shop = Db::getInstance()->execute($sql_shop); - echo "Zaktualizowano produkt z referencją $reference, id_product: " . $id['id_product'] . ", cena: $price, id_tax_rules_group: $id_tax_rules_group, active: $active
"; + echo "Zaktualizowano produkt z referencją $reference, id_product: " . $id['id_product'] . ", cena: $price, active: $active
"; } } - else - { - // update materac_product_shop where id_product = id_product - $sql_shop = 'UPDATE `' . _DB_PREFIX_ . 'product_shop` - SET `price` = ' . (float)$price . ', - `id_tax_rules_group` = ' . (int)$id_tax_rules_group . ', - `active` = ' . (int)$active . ' - WHERE `id_product` = ' . (int)$result; - $result_shop = Db::getInstance()->execute($sql_shop); - if ( !$result_shop ) - echo "Zaktualizowano produkt z referencją $reference, id_product: $result, cena: $price, id_tax_rules_group: $id_tax_rules_group, active: $active
"; - } - // update materac_product_attribute by reference foreach ( $product['combinations'] as $combination ) { - $sql_combination = 'UPDATE `' . _DB_PREFIX_ . 'product_attribute` - SET `price` = ' . (float)$combination['price'] . ' - WHERE `reference` = \'' . pSQL($combination['ean']) . '\''; + $sql_combination = 'UPDATE `' . _DB_PREFIX_ . 'product_attribute` SET `price` = ' . (float)$combination['price'] . ' WHERE `reference` = \'' . pSQL($combination['ean']) . '\''; $result_combination = Db::getInstance()->execute($sql_combination); - // get id_product_attribute from materac_product_attribute where reference = KodEAN-13 - $id_product_attribute = Db::getInstance()->getValue('SELECT id_product_attribute FROM `' . _DB_PREFIX_ . 'product_attribute` WHERE `reference` = \'' . pSQL($combination['ean']) . '\''); - if ( !$result_combination ) + $combination_ids = Db::getInstance()->executeS('SELECT id_product_attribute FROM `' . _DB_PREFIX_ . 'product_attribute` WHERE `reference` = \'' . pSQL($combination['ean']) . '\''); + foreach ( $combination_ids as $id_combination ) { - echo "Error: Cannot update product attribute with reference " . $combination['ean'] . "
"; - continue; + $sql_combination_shop = 'UPDATE `' . _DB_PREFIX_ . 'product_attribute_shop` SET `price` = ' . (float)$combination['price'] . ' WHERE `id_product_attribute` = ' . (int)$id_combination['id_product_attribute']; + $result_combination_shop = Db::getInstance()->execute($sql_combination_shop); + echo "Zaktualizowano kombinację z referencją " . $combination['ean'] . ", id_product_attribute: " . $id_combination['id_product_attribute'] . ", cena: " . $combination['price'] . "
"; } - - // update materac_product_attribute_shop where id_product_attribute = id_product_attribute - $sql_combination_shop = 'UPDATE `' . _DB_PREFIX_ . 'product_attribute_shop` - SET `price` = ' . (float)$combination['price'] . ' - WHERE `id_product_attribute` = ' . (int)$id_product_attribute; - $result_combination_shop = Db::getInstance()->execute($sql_combination_shop); } - echo "Zaktualizowano kombinacje dla produktu z referencją $reference
"; } exit;