feat(import-product): Update tax rules and disable products with "AMZ" in name

- Added logic to find and update products containing " AMZ" in their names, setting their tax rules to 62 and disabling them.
- Modified product category assignments based on new criteria.
- Updated product and product_shop tables to reflect changes in tax rules and active status.
- Adjusted logic for handling product features and manufacturers.
- Enhanced logging and error handling for better traceability during import.
This commit is contained in:
2025-05-31 20:37:37 +02:00
parent caee1fc2fb
commit 528cfaba20
2 changed files with 685 additions and 242 deletions

View File

@@ -167,7 +167,111 @@
"lmtime": 1743172736455,
"modified": true
},
"config": {},
"config": {
"addons": {},
"config_dev.yml": {
"type": "-",
"size": 1541,
"lmtime": 0,
"modified": false
},
"config_legacy_dev.yml": {
"type": "-",
"size": 47,
"lmtime": 0,
"modified": false
},
"config_legacy_prod.yml": {
"type": "-",
"size": 163,
"lmtime": 0,
"modified": false
},
"config_legacy_test.yml": {
"type": "-",
"size": 47,
"lmtime": 0,
"modified": false
},
"config_legacy.yml": {
"type": "-",
"size": 590,
"lmtime": 0,
"modified": false
},
"config_prod.yml": {
"type": "-",
"size": 715,
"lmtime": 0,
"modified": false
},
"config_test.yml": {
"type": "-",
"size": 1001,
"lmtime": 0,
"modified": false
},
"config.yml": {
"type": "-",
"size": 4094,
"lmtime": 0,
"modified": false
},
"doctrine.yml": {
"type": "-",
"size": 880,
"lmtime": 0,
"modified": false
},
"parameters.php": {
"type": "-",
"size": 1020,
"lmtime": 1746397929619,
"modified": false
},
"parameters.yml": {
"type": "-",
"size": 11,
"lmtime": 0,
"modified": false
},
"parameters.yml.dist": {
"type": "-",
"size": 983,
"lmtime": 0,
"modified": false
},
"routing_dev.yml": {
"type": "-",
"size": 1132,
"lmtime": 0,
"modified": false
},
"routing.yml": {
"type": "-",
"size": 315,
"lmtime": 0,
"modified": false
},
"security.yml": {
"type": "-",
"size": 631,
"lmtime": 0,
"modified": false
},
"services.yml": {
"type": "-",
"size": 258,
"lmtime": 0,
"modified": false
},
"set_parameters.php": {
"type": "-",
"size": 3096,
"lmtime": 0,
"modified": false
}
},
".DS_Store": {
"type": "-",
"size": 6148,
@@ -2628,6 +2732,304 @@
"ps_accounts": {},
"ps_banner": {},
"ps_buybuttonlite": {},
"ps_cashondelivery": {
"composer.json": {
"type": "-",
"size": 1072,
"lmtime": 1742566353000,
"modified": false
},
"composer.lock": {
"type": "-",
"size": 51498,
"lmtime": 1742566352000,
"modified": false
},
"config_pl.xml": {
"type": "-",
"size": 482,
"lmtime": 1742566352000,
"modified": false
},
"config.xml": {
"type": "-",
"size": 496,
"lmtime": 1742566352000,
"modified": false
},
"controllers": {
"front": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"modified": false
},
"validation.php": {
"type": "-",
"size": 4122,
"lmtime": 1742566357000,
"modified": false
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"modified": false
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566352000,
"modified": false
},
"LICENSE.md": {
"type": "-",
"size": 10329,
"lmtime": 1742566351000,
"modified": false
},
"logo.png": {
"type": "-",
"size": 8755,
"lmtime": 1742566352000,
"modified": false
},
"logo.webp": {
"type": "-",
"size": 716,
"lmtime": 1742566352000,
"modified": false
},
"ps_cashondelivery.php": {
"type": "-",
"size": 12104,
"lmtime": 1742566352000,
"modified": false
},
"README.md": {
"type": "-",
"size": 863,
"lmtime": 1742567048000,
"modified": false
},
"tests": {
"index.php": {
"type": "-",
"size": 1271,
"lmtime": 1742566354000,
"modified": false
},
"phpstan": {
"index.php": {
"type": "-",
"size": 1271,
"lmtime": 1742566354000,
"modified": false
},
"phpstan-1.7.6.neon": {
"type": "-",
"size": 799,
"lmtime": 1742566355000,
"modified": false
},
"phpstan-1.7.7.neon": {
"type": "-",
"size": 416,
"lmtime": 1742566355000,
"modified": false
},
"phpstan-1.7.8.neon": {
"type": "-",
"size": 185,
"lmtime": 1742566354000,
"modified": false
},
"phpstan-latest.neon": {
"type": "-",
"size": 185,
"lmtime": 1742566354000,
"modified": false
},
"phpstan.neon": {
"type": "-",
"size": 341,
"lmtime": 1742566354000,
"modified": false
}
},
"phpstan.sh": {
"type": "-",
"size": 1074,
"lmtime": 1742566354000,
"modified": false
}
},
"translations": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"modified": false
},
"pl.php": {
"type": "-",
"size": 0,
"lmtime": 1742566356000,
"modified": false
}
},
"upgrade": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"modified": false
},
"upgrade-1.0.7.php": {
"type": "-",
"size": 1252,
"lmtime": 1742566355000,
"modified": false
},
"upgrade-2.0.0.php": {
"type": "-",
"size": 1906,
"lmtime": 1742566355000,
"modified": false
}
},
"vendor": {
"autoload.php": {
"type": "-",
"size": 178,
"lmtime": 1742566353000,
"modified": false
},
"composer": {
"autoload_classmap.php": {
"type": "-",
"size": 317,
"lmtime": 1742566354000,
"modified": false
},
"autoload_namespaces.php": {
"type": "-",
"size": 149,
"lmtime": 1742566354000,
"modified": false
},
"autoload_psr4.php": {
"type": "-",
"size": 143,
"lmtime": 1742566354000,
"modified": false
},
"autoload_real.php": {
"type": "-",
"size": 1453,
"lmtime": 1742566353000,
"modified": false
},
"autoload_static.php": {
"type": "-",
"size": 656,
"lmtime": 1742566353000,
"modified": false
},
"ClassLoader.php": {
"type": "-",
"size": 13420,
"lmtime": 1742566353000,
"modified": false
},
"installed.json": {
"type": "-",
"size": 3,
"lmtime": 1742566353000,
"modified": false
},
"LICENSE": {
"type": "-",
"size": 1070,
"lmtime": 1742566353000,
"modified": false
}
}
},
"views": {
"img": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"modified": false
},
"orderstate": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"modified": false
},
"PS_OS_COD_VALIDATION.gif": {
"type": "-",
"size": 1028,
"lmtime": 1742566356000,
"modified": false
}
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"modified": false
},
"templates": {
"hook": {
"displayOrderConfirmation.tpl": {
"type": "-",
"size": 1390,
"lmtime": 1742566356000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"modified": false
},
"paymentOptions-additionalInformation.tpl": {
"type": "-",
"size": 999,
"lmtime": 1742566356000,
"modified": false
},
"payment_return.tpl": {
"type": "-",
"size": 1470,
"lmtime": 1742566356000,
"modified": false
},
"ps_cashondelivery_intro.tpl": {
"type": "-",
"size": 1090,
"lmtime": 1742566356000,
"modified": false
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"modified": false
}
}
}
},
"ps_categorytree": {},
"ps_checkout": {},
"ps_checkpayment": {},
@@ -3564,299 +3966,248 @@
"statssearch": {},
"statsstock": {},
"welcome": {},
"ps_cashondelivery": {
"composer.json": {
"type": "-",
"size": 1072,
"lmtime": 1742566353000,
"modified": false
},
"composer.lock": {
"type": "-",
"size": 51498,
"lmtime": 1742566352000,
"modified": false
"import_api": {
"classes": {
"convertor.php": {
"type": "-",
"size": 18369,
"lmtime": 1742565820000,
"modified": false
},
"creator.php": {
"type": "-",
"size": 27758,
"lmtime": 1742565821000,
"modified": false
},
"filereader.php": {
"type": "-",
"size": 12700,
"lmtime": 1742565820000,
"modified": false
},
"import.php": {
"type": "-",
"size": 17379,
"lmtime": 1742565821000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1304,
"lmtime": 1742565821000,
"modified": false
},
"queue.php": {
"type": "-",
"size": 4852,
"lmtime": 1742565821000,
"modified": false
}
},
"config_pl.xml": {
"type": "-",
"size": 482,
"lmtime": 1742566352000,
"size": 494,
"lmtime": 1742565820000,
"modified": false
},
"config.xml": {
"type": "-",
"size": 496,
"lmtime": 1742566352000,
"size": 505,
"lmtime": 1742565819000,
"modified": false
},
"controllers": {
"front": {
"index.php": {
"admin": {
"AdminImport_ApiController.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"size": 36012,
"lmtime": 1742565824000,
"modified": false
}
},
"front": {
"ajax.php": {
"type": "-",
"size": 3292,
"lmtime": 1742565824000,
"modified": false
},
"validation.php": {
"import.php": {
"type": "-",
"size": 4122,
"lmtime": 1742566357000,
"size": 22299,
"lmtime": 1742565823000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1300,
"lmtime": 1742565824000,
"modified": false
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"size": 1300,
"lmtime": 1742565823000,
"modified": false
}
},
"import_api.php": {
"type": "-",
"size": 3460,
"lmtime": 1742565819000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566352000,
"size": 1304,
"lmtime": 1742565820000,
"modified": false
},
"LICENSE.md": {
"type": "-",
"size": 10329,
"lmtime": 1742566351000,
"modified": false
},
"logo.png": {
"type": "-",
"size": 8755,
"lmtime": 1742566352000,
"modified": false
},
"logo.webp": {
"type": "-",
"size": 716,
"lmtime": 1742566352000,
"modified": false
},
"ps_cashondelivery.php": {
"type": "-",
"size": 12104,
"lmtime": 1742566352000,
"modified": false
},
"README.md": {
"type": "-",
"size": 863,
"lmtime": 1742567048000,
"modified": false
},
"tests": {
"index.php": {
"lib": {
"SimpleXLS.php": {
"type": "-",
"size": 1271,
"lmtime": 1742566354000,
"size": 41367,
"lmtime": 1742565820000,
"modified": false
},
"phpstan": {
"index.php": {
"type": "-",
"size": 1271,
"lmtime": 1742566354000,
"modified": false
},
"phpstan-1.7.6.neon": {
"type": "-",
"size": 799,
"lmtime": 1742566355000,
"modified": false
},
"phpstan-1.7.7.neon": {
"type": "-",
"size": 416,
"lmtime": 1742566355000,
"modified": false
},
"phpstan-1.7.8.neon": {
"type": "-",
"size": 185,
"lmtime": 1742566354000,
"modified": false
},
"phpstan-latest.neon": {
"type": "-",
"size": 185,
"lmtime": 1742566354000,
"modified": false
},
"phpstan.neon": {
"type": "-",
"size": 341,
"lmtime": 1742566354000,
"modified": false
}
},
"phpstan.sh": {
"SimpleXLSX.php": {
"type": "-",
"size": 1074,
"lmtime": 1742566354000,
"size": 27906,
"lmtime": 1742565820000,
"modified": false
}
},
"logo.png": {
"type": "-",
"size": 548,
"lmtime": 1742565820000,
"modified": false
},
"sql_install.php": {
"type": "-",
"size": 3337,
"lmtime": 1742565820000,
"modified": false
},
"translations": {
"index.php": {
"cs.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566357000,
"size": 0,
"lmtime": 1742565823000,
"modified": false
},
"pl.php": {
"type": "-",
"size": 0,
"lmtime": 1742566356000,
"lmtime": 1742565823000,
"modified": false
}
},
"upgrade": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"modified": false
},
"upgrade-1.0.7.php": {
"type": "-",
"size": 1252,
"lmtime": 1742566355000,
"modified": false
},
"upgrade-2.0.0.php": {
"type": "-",
"size": 1906,
"lmtime": 1742566355000,
"modified": false
}
},
"vendor": {
"autoload.php": {
"type": "-",
"size": 178,
"lmtime": 1742566353000,
"modified": false
},
"composer": {
"autoload_classmap.php": {
"type": "-",
"size": 317,
"lmtime": 1742566354000,
"modified": false
},
"autoload_namespaces.php": {
"type": "-",
"size": 149,
"lmtime": 1742566354000,
"modified": false
},
"autoload_psr4.php": {
"type": "-",
"size": 143,
"lmtime": 1742566354000,
"modified": false
},
"autoload_real.php": {
"type": "-",
"size": 1453,
"lmtime": 1742566353000,
"modified": false
},
"autoload_static.php": {
"type": "-",
"size": 656,
"lmtime": 1742566353000,
"modified": false
},
"ClassLoader.php": {
"type": "-",
"size": 13420,
"lmtime": 1742566353000,
"modified": false
},
"installed.json": {
"type": "-",
"size": 3,
"lmtime": 1742566353000,
"modified": false
},
"LICENSE": {
"type": "-",
"size": 1070,
"lmtime": 1742566353000,
"modified": false
}
}
},
"views": {
"img": {
"index.php": {
"css": {
"dataTables.bootstrap4.css": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"size": 6005,
"lmtime": 1742565821000,
"modified": false
},
"orderstate": {
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"modified": false
},
"PS_OS_COD_VALIDATION.gif": {
"type": "-",
"size": 1028,
"lmtime": 1742566356000,
"modified": false
}
}
},
"img": {},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566355000,
"size": 1304,
"lmtime": 1742565821000,
"modified": false
},
"js": {
"back.js": {
"type": "-",
"size": 1115,
"lmtime": 1742565823000,
"modified": false
},
"dataTables.bootstrap4.js": {
"type": "-",
"size": 4877,
"lmtime": 1742565823000,
"modified": false
},
"dataTables.js": {
"type": "-",
"size": 463898,
"lmtime": 1742565823000,
"modified": false
},
"dataTables.min.js": {
"type": "-",
"size": 82816,
"lmtime": 1742565822000,
"modified": false
},
"front.js": {
"type": "-",
"size": 1115,
"lmtime": 1742565823000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1304,
"lmtime": 1742565823000,
"modified": false
}
},
"templates": {
"hook": {
"displayOrderConfirmation.tpl": {
"admin": {
"configure.tpl": {
"type": "-",
"size": 1390,
"lmtime": 1742566356000,
"size": 2597,
"lmtime": 1742565822000,
"modified": false
},
"delete.tpl": {
"type": "-",
"size": 2485,
"lmtime": 1742565822000,
"modified": false
},
"file_upload.tpl": {
"type": "-",
"size": 3861,
"lmtime": 1742565822000,
"modified": false
},
"import.tpl": {
"type": "-",
"size": 6791,
"lmtime": 1742565822000,
"modified": false
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"size": 1304,
"lmtime": 1742565822000,
"modified": false
},
"paymentOptions-additionalInformation.tpl": {
"list.tpl": {
"type": "-",
"size": 999,
"lmtime": 1742566356000,
"size": 1191,
"lmtime": 1742565822000,
"modified": false
},
"payment_return.tpl": {
"temp.tpl": {
"type": "-",
"size": 1470,
"lmtime": 1742566356000,
"modified": false
},
"ps_cashondelivery_intro.tpl": {
"type": "-",
"size": 1090,
"lmtime": 1742566356000,
"size": 5618,
"lmtime": 1742565822000,
"modified": false
}
},
"index.php": {
"type": "-",
"size": 1127,
"lmtime": 1742566356000,
"size": 1304,
"lmtime": 1742565821000,
"modified": false
}
}

View File

@@ -3,6 +3,57 @@
include(dirname(__FILE__) . '/config/config.inc.php');
include(dirname(__FILE__) . '/init.php');
// Pobierz aktualny język kontekstu (ustaw odpowiedni ID języka, np. 1 dla polskiego)
$id_lang = Context::getContext()->language->id;
// Znajdź wszystkie produkty, których nazwa zawiera " AMZ"
$sql = '
SELECT p.`id_product`
FROM `' . _DB_PREFIX_ . 'product_lang` pl
JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = pl.`id_product`
WHERE pl.`id_lang` = ' . (int)$id_lang . '
AND pl.`name` LIKE \'% AMZ%\'
';
$products = Db::getInstance()->executeS($sql);
if (!empty($products)) {
foreach ($products as $row) {
$id_product = (int)$row['id_product'];
// Ustaw id_tax_rules_group = 62 w tabeli product
Db::getInstance()->update(
'product',
['id_tax_rules_group' => 62],
'id_product = ' . $id_product
);
// Ustaw id_tax_rules_group = 62 w tabeli product_shop (dla sklepu o ID = 1)
Db::getInstance()->update(
'product_shop',
['id_tax_rules_group' => 62],
'id_product = ' . $id_product
);
// disable product
Db::getInstance()->update(
'product',
['active' => 0],
'id_product = ' . $id_product
);
Db::getInstance()->update(
'product_shop',
['active' => 0],
'id_product = ' . $id_product
);
}
echo 'Zaktualizowano stawkę VAT (62) dla wszystkich produktów zawierających "AMZ" w nazwie.';
} else {
echo 'Nie znaleziono produktów z "AMZ" w nazwie.';
}
die( '-- Import zakończony --' );
// Load XML file
libxml_use_internal_errors(true);
$xmlString = file_get_contents('https://cdn.projectpro.pl/drmaterac.pl/produkty-amz.xml');
@@ -15,6 +66,9 @@ if (!$xml) {
die("Error: Cannot parse XML");
}
$config['update_price'] = false; // Ustaw na true, jeśli chcesz aktualizować ceny produktów
$config['update_tax_id'] = true; // Ustaw na true, jeśli chcesz aktualizować ID podatku
// Logowanie czasu wykonania
function logTime($message, $startTime) {
file_put_contents('import_log.txt', $message . ' - Czas: ' . round(microtime(true) - $startTime, 10) . " s\n", FILE_APPEND);
@@ -192,15 +246,15 @@ function findCombinationByAttributes($id_product, $attributeIds) {
$sql = '
SELECT pa.id_product_attribute
FROM ps_product_attribute pa
JOIN ps_product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
FROM materac_product_attribute pa
JOIN materac_product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
WHERE pa.id_product = '.(int)$id_product;
$combinations = Db::getInstance()->executeS($sql);
foreach ($combinations as $combo) {
$comboAttrIds = Db::getInstance()->executeS('
SELECT id_attribute FROM ps_product_attribute_combination
SELECT id_attribute FROM materac_product_attribute_combination
WHERE id_product_attribute = '.(int)$combo['id_product_attribute'].'
');
$comboAttrIds = array_column($comboAttrIds, 'id_attribute');
@@ -302,7 +356,7 @@ function importProductFeatures($productId, $featuresString) {
$featureId = $feature->id;
}
if ( $featureId == 21 or $featureId == 36 )
if ( $featureId == 47 or $featureId == 76 )
continue;
$featureValueId = Db::getInstance()->getValue(
@@ -401,9 +455,9 @@ foreach ($productsBySymbol as $symbol => $products)
$amz_category = (string)$mainProductData->Kategorieproduktu;
if ( strpos( $amz_category, 'Kołdry' ) !== false ) {
$id_category_default = 124;
$id_category_default = 60;
} elseif ( strpos( $amx_category, 'Poduszka' ) !== false or strpos( $amz_category, 'poduszka' ) !== false or strpos( $amz_category, 'Poduszki' ) !== false ) {
$id_category_default = 117;
$id_category_default = 61;
} else {
$id_category_default = 2;
}
@@ -425,13 +479,15 @@ foreach ($productsBySymbol as $symbol => $products)
$mainProduct->id_category_default = $id_category_default;
$mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
$mainProduct->id_shop_list = [1]; // Przypisanie do sklepów
$mainProduct->active = 1; // Ustawienie produktu jako aktywnego
$mainProduct->id_tax_rules_group = 62; // Ustawienie ID grupy reguł podatkowych
$mainProduct->add();
// ❗ Teraz przypisanie do kategorii
$mainProduct->updateCategories([$id_category_default, $id_category_default]);
foreach ($categories as $catId) {
foreach ([1] as $shopId) { // tu wpisz ID sklepu, np. 2
foreach ([2] as $shopId) { // tu wpisz ID sklepu, np. 2
Db::getInstance()->insert('category_product', [
'id_category' => (int)$catId,
'id_product' => (int)$mainProduct->id,
@@ -460,21 +516,57 @@ foreach ($productsBySymbol as $symbol => $products)
$mainProduct->checkDefaultAttributes();
Product::updateDefaultAttribute($mainProduct->id);
assignFeatureToProduct($mainProduct->id, 11, 157);
assignManufacturerToProduct($mainProduct->id, 32);
assignFeatureToProduct($mainProduct->id, 41, 2499);
assignManufacturerToProduct($mainProduct->id, 53);
updateDeliveryParameters($mainProduct->id);
$productAdded = true;
}
else
{
if ( $config['update_price'] == true )
if ( $config['update_price'] == true and $mainProduct ->id != 35873 )
{
$mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
$description = (string)$mainProductData->description;
$description = str_replace("\n", "<br>", $description);
$mainProduct->description = createMultiLangField($description);
$mainProduct->update();
// $mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
// $description = (string)$mainProductData->description;
// $description = str_replace("\n", "<br>", $description);
// $mainProduct->description = createMultiLangField($description);
// $mainProduct->update();
// update price new price is old brutto price / 1.23
// get price brutto from db
// $oldPrice = Db::getInstance()->getValue('SELECT price FROM '._DB_PREFIX_.'product WHERE id_product = '.(int)$mainProduct->id);
// $newPrice = floatval(str_replace(',', '', $mainProductData->price)) / 1.23; // assuming old price is brutto
// // update price in product table
// Db::getInstance()->update('product', ['price' => $newPrice], 'id_product = '.(int)$mainProduct->id);
// // update price in product_shop table
// Db::getInstance()->update('product_shop', ['price' => $newPrice], 'id_product = '.(int)$mainProduct->id);
// echo "<p>Zaktualizowałem cenę produktu: " . (string)$mainProductData->title . " na " . $newPrice . "</p>";
// // do the same with combinations
// // get all combinations for the product from db
// $combinations = Db::getInstance()->executeS('SELECT id_product_attribute FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$mainProduct->id);
// foreach ($combinations as $combination) {
// // get old price from db
// $oldCombinationPrice = Db::getInstance()->getValue('SELECT price FROM '._DB_PREFIX_.'product_attribute WHERE id_product_attribute = '.(int)$combination['id_product_attribute']);
// $newCombinationPrice = floatval(str_replace(',', '', $oldCombinationPrice)) / 1.23; // assuming old price is brutto
// // update price in product_attribute table
// Db::getInstance()->update('product_attribute', ['price' => $newCombinationPrice], 'id_product_attribute = '.(int)$combination['id_product_attribute']);
// // // update price in product_attribute_shop table
// Db::getInstance()->update('product_attribute_shop', ['price' => $newCombinationPrice], 'id_product_attribute = '.(int)$combination['id_product_attribute']);
// echo "<p>Zaktualizowałem cenę kombinacji: " . (string)$mainProductData->title . " na " . $newCombinationPrice . "</p>";
// }
}
if ( $config['update_tax_id'] == true )
{
// Update tax ID in product column id_tax_rules_group, value 62, table materac_product
Db::getInstance()->update('product', ['id_tax_rules_group' => 62], 'id_product = '.(int)$mainProduct->id );
// also table materac_product_shop
Db::getInstance()->update('product_shop', ['id_tax_rules_group' => 62], 'id_product = '.(int)$mainProduct->id );
// change product to active by db
Db::getInstance()->update('product', ['active' => 1], 'id_product = '.(int)$mainProduct->id);
Db::getInstance()->update('product_shop', ['active' => 1], 'id_product = '.(int)$mainProduct->id );
}
}
@@ -576,13 +668,13 @@ foreach ($productsBySymbol as $symbol => $products)
echo "<p>Dodałem produkt: " . (string)$mainProductData->title . "</p>";
}
if ($combinationAdded) {
echo "<p>Dodałem kombinację: " . (string)$mainProductData->title . "</p>";
echo "<p>Dodałem kombinację: " . (string)$mainProductData->title . ". Produkt ID: " . $mainProduct->id . "</p>";
}
break; // Break if a new product or combination was added
}
}
// reload page after 1s if product or combination was added
if ($productAdded || $combinationAdded) {
echo "<script>setTimeout(function(){location.reload();}, 250);</script>";
// echo "<script>setTimeout(function(){location.reload();}, 250);</script>";
}
?>