Fix navbar megamenu styling for the seventh list item to ensure proper targeting of anchor elements
This commit is contained in:
267
.vscode/ftp-kr.sync.cache.json
vendored
267
.vscode/ftp-kr.sync.cache.json
vendored
@@ -26,9 +26,9 @@
|
||||
"cache": {},
|
||||
"-cart_default.jpg": {
|
||||
"type": "-",
|
||||
"size": 3683,
|
||||
"size": 2720,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"classes": {},
|
||||
"composer.lock": {
|
||||
@@ -61,9 +61,9 @@
|
||||
},
|
||||
"-home_default.jpg": {
|
||||
"type": "-",
|
||||
"size": 9320,
|
||||
"size": 7402,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
".htaccess": {
|
||||
"type": "-",
|
||||
@@ -134,8 +134,8 @@
|
||||
"img": {},
|
||||
"import-drewmax.php": {
|
||||
"type": "-",
|
||||
"size": 24566,
|
||||
"lmtime": 0,
|
||||
"size": 32286,
|
||||
"lmtime": 1765839405797,
|
||||
"modified": false
|
||||
},
|
||||
"import-product.php": {
|
||||
@@ -164,9 +164,9 @@
|
||||
},
|
||||
".jpg": {
|
||||
"type": "-",
|
||||
"size": 626142,
|
||||
"size": 440848,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"js": {},
|
||||
"komplet-produktow-3.xml": {
|
||||
@@ -177,9 +177,9 @@
|
||||
},
|
||||
"-large_default.jpg": {
|
||||
"type": "-",
|
||||
"size": 64102,
|
||||
"size": 61644,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"LICENSES": {
|
||||
"type": "-",
|
||||
@@ -197,11 +197,242 @@
|
||||
},
|
||||
"-medium_default.jpg": {
|
||||
"type": "-",
|
||||
"size": 23382,
|
||||
"size": 20567,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"modules": {
|
||||
"gm_omniprice": {
|
||||
"CHANGELOG": {
|
||||
"type": "-",
|
||||
"size": 5258,
|
||||
"lmtime": 1764184727462,
|
||||
"modified": false
|
||||
},
|
||||
"cleanup.php": {
|
||||
"type": "-",
|
||||
"size": 350,
|
||||
"lmtime": 1764184727462,
|
||||
"modified": false
|
||||
},
|
||||
"config_pl.xml": {
|
||||
"type": "-",
|
||||
"size": 556,
|
||||
"lmtime": 1764184727462,
|
||||
"modified": false
|
||||
},
|
||||
"controllers": {
|
||||
"front": {
|
||||
"cron.php": {
|
||||
"type": "-",
|
||||
"size": 4477,
|
||||
"lmtime": 1765828878778,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1321,
|
||||
"lmtime": 1764184727464,
|
||||
"modified": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"cron.php": {
|
||||
"type": "-",
|
||||
"size": 1492,
|
||||
"lmtime": 1764184727464,
|
||||
"modified": false
|
||||
},
|
||||
".DS_Store": {
|
||||
"type": "-",
|
||||
"size": 6148,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"fill.php": {
|
||||
"type": "-",
|
||||
"size": 348,
|
||||
"lmtime": 1764184727465,
|
||||
"modified": false
|
||||
},
|
||||
"gm_omniprice.php": {
|
||||
"type": "-",
|
||||
"size": 100447,
|
||||
"lmtime": 1765828878780,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727466,
|
||||
"modified": false
|
||||
},
|
||||
"logo.png": {
|
||||
"type": "-",
|
||||
"size": 4539,
|
||||
"lmtime": 1764184727466,
|
||||
"modified": false
|
||||
},
|
||||
"logo.webp": {
|
||||
"type": "-",
|
||||
"size": 1980,
|
||||
"lmtime": 1764184727467,
|
||||
"modified": false
|
||||
},
|
||||
"template.php": {
|
||||
"type": "-",
|
||||
"size": 1926,
|
||||
"lmtime": 1764184727467,
|
||||
"modified": false
|
||||
},
|
||||
"translations": {
|
||||
"de.php": {
|
||||
"type": "-",
|
||||
"size": 9540,
|
||||
"lmtime": 1764184727468,
|
||||
"modified": false
|
||||
},
|
||||
"es.php": {
|
||||
"type": "-",
|
||||
"size": 9589,
|
||||
"lmtime": 1764184727469,
|
||||
"modified": false
|
||||
},
|
||||
"fr.php": {
|
||||
"type": "-",
|
||||
"size": 9585,
|
||||
"lmtime": 1764184727469,
|
||||
"modified": false
|
||||
},
|
||||
"it.php": {
|
||||
"type": "-",
|
||||
"size": 9493,
|
||||
"lmtime": 1764184727470,
|
||||
"modified": false
|
||||
},
|
||||
"nl.php": {
|
||||
"type": "-",
|
||||
"size": 0,
|
||||
"lmtime": 1764184727470,
|
||||
"modified": false
|
||||
},
|
||||
"pl.php": {
|
||||
"type": "-",
|
||||
"size": 9307,
|
||||
"lmtime": 1764184727471,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"upgrade": {
|
||||
"upgrade-1.0.10.php": {
|
||||
"type": "-",
|
||||
"size": 170,
|
||||
"lmtime": 1764184727471,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.0.11.php": {
|
||||
"type": "-",
|
||||
"size": 170,
|
||||
"lmtime": 1764184727472,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.0.13.php": {
|
||||
"type": "-",
|
||||
"size": 333,
|
||||
"lmtime": 1764184727472,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.1.0.php": {
|
||||
"type": "-",
|
||||
"size": 195,
|
||||
"lmtime": 1764184727473,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.1.11.php": {
|
||||
"type": "-",
|
||||
"size": 196,
|
||||
"lmtime": 1764184727473,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.2.0.php": {
|
||||
"type": "-",
|
||||
"size": 191,
|
||||
"lmtime": 1764184727473,
|
||||
"modified": false
|
||||
},
|
||||
"upgrade-1.2.3.php": {
|
||||
"type": "-",
|
||||
"size": 190,
|
||||
"lmtime": 1764184727474,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"views": {
|
||||
"css": {
|
||||
"gm_omniprice.css": {
|
||||
"type": "-",
|
||||
"size": 87,
|
||||
"lmtime": 1764184727475,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727475,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727475,
|
||||
"modified": false
|
||||
},
|
||||
"js": {
|
||||
"gm_omniprice.js": {
|
||||
"type": "-",
|
||||
"size": 543,
|
||||
"lmtime": 1764184727476,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727476,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"templates": {
|
||||
"hook": {
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727477,
|
||||
"modified": false
|
||||
},
|
||||
"price.tpl": {
|
||||
"type": "-",
|
||||
"size": 516,
|
||||
"lmtime": 1764184727478,
|
||||
"modified": false
|
||||
},
|
||||
"tab.tpl": {
|
||||
"type": "-",
|
||||
"size": 1009,
|
||||
"lmtime": 1764184727478,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1304,
|
||||
"lmtime": 1764184727478,
|
||||
"modified": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"modules": {},
|
||||
"override": {
|
||||
"classes": {
|
||||
"assets": {},
|
||||
@@ -297,9 +528,9 @@
|
||||
},
|
||||
"-small_default.jpg": {
|
||||
"type": "-",
|
||||
"size": 2570,
|
||||
"size": 2056,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"src": {},
|
||||
"themes": {},
|
||||
@@ -308,9 +539,15 @@
|
||||
"translations": {},
|
||||
"update_price_log.csv": {
|
||||
"type": "-",
|
||||
<<<<<<< HEAD
|
||||
"size": 23674,
|
||||
"lmtime": 1765784209430,
|
||||
"modified": false
|
||||
=======
|
||||
"size": 24168,
|
||||
"lmtime": 0,
|
||||
"modified": true
|
||||
>>>>>>> f00bc6bbc467025557df943e2844498f47b8174d
|
||||
},
|
||||
"upload": {},
|
||||
"var": {},
|
||||
|
||||
@@ -8,11 +8,12 @@ include(dirname(__FILE__).'/init.php');
|
||||
$context = Context::getContext();
|
||||
|
||||
// Sprawdzenie trybu działania na podstawie parametrów URL
|
||||
$modeAdd = (Tools::getValue('add') === 'true');
|
||||
$modeAdd = (Tools::getValue('add') === 'true');
|
||||
$modeUpdate = (Tools::getValue('update') === 'true');
|
||||
$modeSynch = (Tools::getValue('synch') === 'true');
|
||||
|
||||
if (!$modeAdd && !$modeUpdate) {
|
||||
die('Brak akcji. Dodaj do adresu ?add=true lub ?update=true');
|
||||
if (!$modeAdd && !$modeUpdate && !$modeSynch) {
|
||||
die('Brak akcji. Dodaj do adresu ?add=true lub ?update=true lub ?synch=true');
|
||||
}
|
||||
|
||||
// Plik logu aktualizacji cen
|
||||
@@ -298,6 +299,18 @@ function getTaxRulesGroupIdForRate($rate, $id_country = null) {
|
||||
return $id ? (int)$id : 0;
|
||||
}
|
||||
|
||||
// Zwraca główny produkt z grupy – pierwszy, którego SKU istnieje w PrestaShop
|
||||
function findMainProductDataFromGroup($products) {
|
||||
foreach ($products as $p) {
|
||||
$ref = (string)$p->sku;
|
||||
if ($ref !== '' && findProductByReference($ref)) {
|
||||
return $p; // to główny produkt
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// === GRUPOWANIE PRODUKTÓW PO SYMBOLU ===
|
||||
$productsBySymbol = [];
|
||||
foreach ($xml->product as $productData) {
|
||||
@@ -337,17 +350,20 @@ if ($modeUpdate) {
|
||||
|
||||
$updatedSomething = false;
|
||||
|
||||
|
||||
foreach ($productsBySymbol as $symbol => $products) {
|
||||
if (empty($products)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Główny produkt – wybieramy deterministycznie (najniższe SKU alfabetycznie)
|
||||
// aby uniknąć problemu ze zmianą kolejności w XML
|
||||
usort($products, function($a, $b) {
|
||||
return strcmp((string)$a->sku, (string)$b->sku);
|
||||
});
|
||||
$mainProductData = $products[0];
|
||||
// Główny produkt – referencja z pierwszego elementu grupy
|
||||
// $mainProductData = $products[0];
|
||||
// $reference = (string)$mainProductData->sku;
|
||||
// $key = 'product_'.$reference;
|
||||
$mainProductData = findMainProductDataFromGroup($products);
|
||||
if (!$mainProductData) {
|
||||
continue; // w grupie nie ma produktu, który istnieje w Presta
|
||||
}
|
||||
$reference = (string)$mainProductData->sku;
|
||||
$key = 'product_'.$reference;
|
||||
|
||||
@@ -484,7 +500,7 @@ if ($modeUpdate) {
|
||||
}
|
||||
|
||||
if ($updatedSomething) {
|
||||
echo '<script>setTimeout(function(){ location.reload(); }, 50);</script>';
|
||||
// echo '<script>setTimeout(function(){ location.reload(); }, 50);</script>';
|
||||
} else {
|
||||
echo '<p>Brak produktów do aktualizacji na dzisiaj (wszystkie z XML zostały już zaktualizowane).</p>';
|
||||
}
|
||||
@@ -495,161 +511,338 @@ if ($modeUpdate) {
|
||||
// =======================================
|
||||
// =========== TRYB DODAWANIA ============
|
||||
// =======================================
|
||||
if ($modeAdd) {
|
||||
$productAdded = false;
|
||||
$combinationAdded = false;
|
||||
|
||||
$productAdded = false;
|
||||
$combinationAdded = false;
|
||||
|
||||
// Tworzenie lub aktualizacja produktów z kombinacjami (dodawanie)
|
||||
foreach ($productsBySymbol as $symbol => $products) {
|
||||
if (empty($products)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Główny produkt – wybieramy deterministycznie (najniższe SKU alfabetycznie)
|
||||
// aby uniknąć problemu ze zmianą kolejności w XML
|
||||
usort($products, function($a, $b) {
|
||||
return strcmp((string)$a->sku, (string)$b->sku);
|
||||
});
|
||||
$mainProductData = $products[0];
|
||||
$mainProduct = findProductByReference((string)$mainProductData->sku);
|
||||
|
||||
// BAZA: najtańszy wariant w grupie (brutto i netto)
|
||||
list($grossBase, $netPrice) = getBasePricesFromGroup($products);
|
||||
|
||||
if (!$mainProduct) {
|
||||
// Create a new product if it doesn't exist
|
||||
$mainProduct = new Product();
|
||||
$mainProduct->name = createMultiLangField((string)$mainProductData->title);
|
||||
|
||||
$description = (string)$mainProductData->description;
|
||||
$description = str_replace("\n", "<br>", $description);
|
||||
$mainProduct->description = createMultiLangField($description);
|
||||
|
||||
// Cena BRUTTO z XML -> NETTO (23%) – bazą jest najtańszy wariant
|
||||
$mainProduct->price = $netPrice > 0 ? $netPrice : 0;
|
||||
|
||||
// VAT 23% jeśli dostępny
|
||||
if (!empty($idTaxRulesGroup23)) {
|
||||
$mainProduct->id_tax_rules_group = (int)$idTaxRulesGroup23;
|
||||
// Tworzenie lub aktualizacja produktów z kombinacjami (dodawanie)
|
||||
foreach ($productsBySymbol as $symbol => $products) {
|
||||
if (empty($products)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Produkt aktywny + delivery times
|
||||
$mainProduct->active = 1;
|
||||
$mainProduct->delivery_in_stock = createMultiLangField('2-7 dni roboczych');
|
||||
$mainProduct->delivery_out_stock = createMultiLangField('4-10 tygodni');
|
||||
// ===== Filter item_group_id =====
|
||||
// $mainProductDataTemp = $products[0];
|
||||
// if ((string)$mainProductDataTemp->item_group_id !== '68590') {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$mainProduct->reference = (string)$mainProductData->sku;
|
||||
$mainProduct->id_category_default = 2; // np. Strona główna
|
||||
$mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
|
||||
$mainProduct->add();
|
||||
|
||||
// Add images to the product
|
||||
if (!empty($mainProductData->image)) {
|
||||
addProductImage($mainProduct->id, (string)$mainProductData->image);
|
||||
// Główny produkt – dane z pierwszego w grupie
|
||||
// $mainProductData = $products[0];
|
||||
// $mainProduct = findProductByReference((string)$mainProductData->sku);
|
||||
$mainProductData = findMainProductDataFromGroup($products);
|
||||
if (!$mainProductData) {
|
||||
$mainProductData = $products[0]; // fallback na etapie dodawania
|
||||
}
|
||||
$mainProduct = findProductByReference((string)$mainProductData->sku);
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$imageUrl = (string)$mainProductData->{'images_' . $i};
|
||||
if (!empty($imageUrl)) {
|
||||
addProductImage($mainProduct->id, $imageUrl);
|
||||
// BAZA: najtańszy wariant w grupie (brutto i netto)
|
||||
list($grossBase, $netPrice) = getBasePricesFromGroup($products);
|
||||
|
||||
if (!$mainProduct) {
|
||||
// Create a new product if it doesn't exist
|
||||
$mainProduct = new Product();
|
||||
$mainProduct->name = createMultiLangField((string)$mainProductData->title);
|
||||
|
||||
$description = (string)$mainProductData->description;
|
||||
$description = str_replace("\n", "<br>", $description);
|
||||
$mainProduct->description = createMultiLangField($description);
|
||||
|
||||
// Cena BRUTTO z XML -> NETTO (23%) – bazą jest najtańszy wariant
|
||||
$mainProduct->price = $netPrice > 0 ? $netPrice : 0;
|
||||
|
||||
// VAT 23% jeśli dostępny
|
||||
if (!empty($idTaxRulesGroup23)) {
|
||||
$mainProduct->id_tax_rules_group = (int)$idTaxRulesGroup23;
|
||||
}
|
||||
}
|
||||
|
||||
$productAdded = true;
|
||||
}
|
||||
// Produkt aktywny + delivery times
|
||||
$mainProduct->active = 1;
|
||||
$mainProduct->delivery_in_stock = createMultiLangField('2-7 dni roboczych');
|
||||
$mainProduct->delivery_out_stock = createMultiLangField('4-10 tygodni');
|
||||
|
||||
// Ensure the product is saved before adding combinations
|
||||
if (!$mainProduct->id) {
|
||||
echo "Failed to create or update main product: " . (string)$mainProductData->title . "\n";
|
||||
continue;
|
||||
}
|
||||
$mainProduct->reference = (string)$mainProductData->sku;
|
||||
$mainProduct->id_category_default = 107; // np. Meble
|
||||
$mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
|
||||
$mainProduct->add();
|
||||
|
||||
// Ensure the combination set is unique for the product
|
||||
$addedCombinations = [];
|
||||
// ===== Poprawne przypisanie kategorii =====
|
||||
$id_lang = (int)$context->language->id;
|
||||
$defaultCategory = new Category($mainProduct->id_category_default, $id_lang);
|
||||
|
||||
// Add or update combinations for each product in the group
|
||||
foreach ($products as $productData) {
|
||||
$attributes = [
|
||||
'Kolor' => (string)$productData->Kolor,
|
||||
'Dlugosc' => (string)$productData->Dlugosc,
|
||||
'Szerokosc' => (string)$productData->Szerokosc,
|
||||
'Glebokosc' => (string)$productData->Glebokosc,
|
||||
'Wysokosc' => (string)$productData->Wysokosc,
|
||||
];
|
||||
if (Validate::isLoadedObject($defaultCategory) && $defaultCategory->name == 'Strona główna') {
|
||||
$newCategoryId = 107; // Meble
|
||||
$mainProduct->id_category_default = (int)$newCategoryId;
|
||||
|
||||
$attributeIds = [];
|
||||
foreach ($attributes as $name => $value) {
|
||||
if (!empty($value)) {
|
||||
$attributeGroupId = createAttribute($name, [$value]);
|
||||
$attribute = findAttributeByName($attributeGroupId, $value);
|
||||
if ($attribute) {
|
||||
$attributeIds[] = (int)$attribute->id;
|
||||
// Podmieniamy kategorie produktu (zachowując inne)
|
||||
$categories = $mainProduct->getCategories();
|
||||
$categories = array_diff($categories, [(int)$defaultCategory->id]);
|
||||
$categories[] = (int)$newCategoryId;
|
||||
$categories = array_unique(array_map('intval', $categories));
|
||||
$mainProduct->updateCategories($categories);
|
||||
}
|
||||
// ===== Koniec ustawienia kategorii =====
|
||||
|
||||
// Add images to the product
|
||||
if (!empty($mainProductData->image)) {
|
||||
addProductImage($mainProduct->id, (string)$mainProductData->image);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$imageUrl = (string)$mainProductData->{'images_' . $i};
|
||||
if (!empty($imageUrl)) {
|
||||
addProductImage($mainProduct->id, $imageUrl);
|
||||
}
|
||||
}
|
||||
|
||||
$productAdded = true;
|
||||
}
|
||||
|
||||
// Create a unique key for the attribute set
|
||||
sort($attributeIds);
|
||||
$key = implode('-', $attributeIds);
|
||||
// Ensure the product is saved before adding combinations
|
||||
if (!$mainProduct->id) {
|
||||
echo "Failed to create or update main product: " . (string)$mainProductData->title . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add or update combination if it is unique
|
||||
if (!empty($attributeIds) && !isset($addedCombinations[$key])) {
|
||||
$combination = findCombinationByAttributes($mainProduct->id, $attributeIds);
|
||||
if (!$combination) {
|
||||
// Create new combination
|
||||
$combination = new Combination();
|
||||
$combination->id_product = (int)$mainProduct->id;
|
||||
$combination->quantity = 100; // startowo, i tak zaraz nadpiszemy StockAvailable
|
||||
$combination->reference = (string)$productData->sku;
|
||||
$combination->add();
|
||||
$combination->setAttributes($attributeIds);
|
||||
$combination->save();
|
||||
$combinationAdded = true;
|
||||
} else {
|
||||
// Update existing combination quantity if necessary
|
||||
$combination->quantity = 100; // startowo
|
||||
$combination->update();
|
||||
// Ensure the combination set is unique for the product
|
||||
$addedCombinations = [];
|
||||
|
||||
// Add or update combinations for each product in the group
|
||||
foreach ($products as $productData) {
|
||||
$attributes = [
|
||||
'Kolor' => (string)$productData->Kolor,
|
||||
'Dlugosc' => (string)$productData->Dlugosc,
|
||||
'Szerokosc' => (string)$productData->Szerokosc,
|
||||
'Glebokosc' => (string)$productData->Glebokosc,
|
||||
'Wysokosc' => (string)$productData->Wysokosc,
|
||||
];
|
||||
|
||||
$attributeIds = [];
|
||||
foreach ($attributes as $name => $value) {
|
||||
if (!empty($value)) {
|
||||
$attributeGroupId = createAttribute($name, [$value]);
|
||||
$attribute = findAttributeByName($attributeGroupId, $value);
|
||||
if ($attribute) {
|
||||
$attributeIds[] = (int)$attribute->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark this combination as added
|
||||
$addedCombinations[$key] = true;
|
||||
// Create a unique key for the attribute set
|
||||
sort($attributeIds);
|
||||
$key = implode('-', $attributeIds);
|
||||
|
||||
// Add or update combination if it is unique
|
||||
if (!empty($attributeIds) && !isset($addedCombinations[$key])) {
|
||||
$combination = findCombinationByAttributes($mainProduct->id, $attributeIds);
|
||||
if (!$combination) {
|
||||
// Create new combination
|
||||
$combination = new Combination();
|
||||
$combination->id_product = (int)$mainProduct->id;
|
||||
$combination->quantity = 100; // startowo, i tak zaraz nadpiszemy StockAvailable
|
||||
$combination->reference = (string)$productData->sku;
|
||||
$combination->add();
|
||||
$combination->setAttributes($attributeIds);
|
||||
$combination->save();
|
||||
$combinationAdded = true;
|
||||
} else {
|
||||
// Update existing combination quantity if necessary
|
||||
$combination->quantity = 100; // startowo
|
||||
$combination->update();
|
||||
}
|
||||
|
||||
// Mark this combination as added
|
||||
$addedCombinations[$key] = true;
|
||||
}
|
||||
|
||||
if ($combinationAdded) {
|
||||
break; // Break if a new combination was added
|
||||
}
|
||||
}
|
||||
|
||||
if ($combinationAdded) {
|
||||
break; // Break if a new combination was added
|
||||
// --- STANY MAGAZYNOWE PRODUKTU (ID_PRODUCT_ATTRIBUTE = 0) ---
|
||||
$mainStatus = (string)$mainProductData->Status_magazynowy;
|
||||
$mainQty = ($mainStatus === 'instock') ? 100 : 0;
|
||||
StockAvailable::setQuantity($mainProduct->id, 0, $mainQty);
|
||||
|
||||
// --- STANY MAGAZYNOWE KOMBINACJI ---
|
||||
foreach ($products as $productDataVariant) {
|
||||
$variantRef = (string)$productDataVariant->sku;
|
||||
$variantStatus = (string)$productDataVariant->Status_magazynowy;
|
||||
$variantQty = ($variantStatus === 'instock') ? 100 : 0;
|
||||
|
||||
$combination = findCombinationByReference($mainProduct->id, $variantRef);
|
||||
if ($combination) {
|
||||
StockAvailable::setQuantity($mainProduct->id, $combination->id, $variantQty);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the product has combinations enabled
|
||||
$mainProduct->checkDefaultAttributes();
|
||||
Product::updateDefaultAttribute($mainProduct->id);
|
||||
|
||||
if ($productAdded || $combinationAdded) {
|
||||
if ($productAdded) {
|
||||
echo "<p>Dodałem produkt: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||
}
|
||||
if ($combinationAdded) {
|
||||
echo "<p>Dodałem kombinację: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||
}
|
||||
break; // Break if a new product or combination was added
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- STANY MAGAZYNOWE PRODUKTU (ID_PRODUCT_ATTRIBUTE = 0) ---
|
||||
$mainStatus = (string)$mainProductData->Status_magazynowy;
|
||||
$mainQty = ($mainStatus === 'instock') ? 100 : 0;
|
||||
StockAvailable::setQuantity($mainProduct->id, 0, $mainQty);
|
||||
// =======================================
|
||||
// ========= TRYB SYNCHRONIZACJI =========
|
||||
// =======================================
|
||||
if ($modeSynch) {
|
||||
echo '<h2>Rozpoczynam synchronizację produktów...</h2>';
|
||||
|
||||
// --- STANY MAGAZYNOWE KOMBINACJI ---
|
||||
foreach ($products as $productDataVariant) {
|
||||
$variantRef = (string)$productDataVariant->sku;
|
||||
$variantStatus = (string)$productDataVariant->Status_magazynowy;
|
||||
$variantQty = ($variantStatus === 'instock') ? 100 : 0;
|
||||
$db = Db::getInstance();
|
||||
|
||||
$combination = findCombinationByReference($mainProduct->id, $variantRef);
|
||||
if ($combination) {
|
||||
StockAvailable::setQuantity($mainProduct->id, $combination->id, $variantQty);
|
||||
}
|
||||
// 1. Wyczyszczenie tymczasowej tabeli
|
||||
$db->execute('TRUNCATE TABLE `'._DB_PREFIX_.'drewmax_products_temp`');
|
||||
|
||||
// 1.1 Wczytywanie SKU z XML i dodawanie do tymczasowej tabeli
|
||||
$skusInXml = [];
|
||||
foreach ($xml->product as $productData) {
|
||||
$sku = trim((string)$productData->sku);
|
||||
if ($sku === '') continue;
|
||||
|
||||
$skusInXml[] = $sku;
|
||||
|
||||
$db->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'drewmax_products_temp` (`sku`, `date_checked`)
|
||||
VALUES (\''.pSQL($sku).'\', NOW())
|
||||
');
|
||||
}
|
||||
|
||||
// Ensure the product has combinations enabled
|
||||
$mainProduct->checkDefaultAttributes();
|
||||
Product::updateDefaultAttribute($mainProduct->id);
|
||||
// 2. Praca z historią
|
||||
if (!empty($skusInXml)) {
|
||||
// Utworzenie listy SKU dla SQL
|
||||
$skusList = "'" . implode("','", array_map('pSQL', $skusInXml)) . "'";
|
||||
|
||||
if ($productAdded || $combinationAdded) {
|
||||
if ($productAdded) {
|
||||
echo "<p>Dodałem produkt: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||
}
|
||||
if ($combinationAdded) {
|
||||
echo "<p>Dodałem kombinację: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||
}
|
||||
break; // Break if a new product or combination was added
|
||||
// 2.1 Dodawanie nowych SKU do historii lub przywracanie aktywności
|
||||
$sqlInsert = '
|
||||
INSERT INTO `'._DB_PREFIX_.'drewmax_products_history` (`sku`, `active`)
|
||||
SELECT t.sku, 1
|
||||
FROM `'._DB_PREFIX_.'drewmax_products_temp` t
|
||||
LEFT JOIN `'._DB_PREFIX_.'drewmax_products_history` h ON h.sku = t.sku
|
||||
WHERE h.sku IS NULL
|
||||
';
|
||||
$db->execute($sqlInsert);
|
||||
|
||||
$sqlUpdateActive = '
|
||||
UPDATE `'._DB_PREFIX_.'drewmax_products_history` h
|
||||
JOIN `'._DB_PREFIX_.'drewmax_products_temp` t ON h.sku = t.sku
|
||||
SET h.active = 1
|
||||
WHERE h.active = 0
|
||||
';
|
||||
$db->execute($sqlUpdateActive);
|
||||
}
|
||||
|
||||
// 2.2 Wykluczanie produktów, których nie ma w temp
|
||||
$sqlDeactivate = '
|
||||
UPDATE `'._DB_PREFIX_.'drewmax_products_history` h
|
||||
LEFT JOIN `'._DB_PREFIX_.'drewmax_products_temp` t ON h.sku = t.sku
|
||||
SET h.active = 0
|
||||
WHERE t.sku IS NULL AND h.active = 1
|
||||
';
|
||||
$db->execute($sqlDeactivate);
|
||||
|
||||
// Wyłącz produkty w PrestaShop dla SKU, które mają active=0
|
||||
$skusToDisable = $db->executeS('
|
||||
SELECT sku FROM `'._DB_PREFIX_.'drewmax_products_history`
|
||||
WHERE active = 0
|
||||
');
|
||||
|
||||
// 3. Synchronizacja statusu produktów i kombinacji w PrestaShop
|
||||
// Pobieramy tylko SKU z historii (źródło prawdy)
|
||||
$allHistory = $db->executeS('
|
||||
SELECT sku, active
|
||||
FROM `'._DB_PREFIX_.'drewmax_products_history`
|
||||
');
|
||||
|
||||
foreach ($allHistory as $row) {
|
||||
$sku = trim($row['sku']);
|
||||
$activeStatus = (int)$row['active'];
|
||||
|
||||
if ($sku === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* KROK 3.1
|
||||
* Sprawdzenie czy SKU jest GŁÓWNYM PRODUKTEM
|
||||
* (tylko ps_product.reference)
|
||||
*/
|
||||
$idProduct = (int)$db->getValue('
|
||||
SELECT id_product
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE reference = \''.pSQL($sku).'\'
|
||||
LIMIT 1
|
||||
');
|
||||
|
||||
if ($idProduct > 0) {
|
||||
// === GŁÓWNY PRODUKT ===
|
||||
$product = new Product($idProduct);
|
||||
|
||||
if (!Validate::isLoadedObject($product)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($activeStatus === 0 && (int)$product->active === 1) {
|
||||
// Wyłącz produkt
|
||||
$product->active = 0;
|
||||
$product->update();
|
||||
echo "Wyłączono PRODUKT: {$sku}<br>";
|
||||
}
|
||||
|
||||
if ($activeStatus === 1 && (int)$product->active === 0) {
|
||||
// Włącz produkt
|
||||
$product->active = 1;
|
||||
$product->update();
|
||||
echo "Włączono PRODUKT: {$sku}<br>";
|
||||
}
|
||||
|
||||
// Główny produkt obsłużony → NIE sprawdzamy kombinacji
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* KROK 3.2
|
||||
* Jeśli NIE jest produktem → sprawdzamy czy to KOMBINACJA
|
||||
*/
|
||||
$combinationRow = $db->getRow('
|
||||
SELECT id_product_attribute, id_product
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE reference = \''.pSQL($sku).'\'
|
||||
LIMIT 1
|
||||
');
|
||||
|
||||
if ($combinationRow) {
|
||||
// === KOMBINACJA ===
|
||||
if ($activeStatus === 0) {
|
||||
$idProductAttribute = (int)$combinationRow['id_product_attribute'];
|
||||
|
||||
$combination = new Combination($idProductAttribute);
|
||||
if (Validate::isLoadedObject($combination)) {
|
||||
$combination->delete();
|
||||
echo "Usunięto KOMBINACJĘ: {$sku} (ID: {$idProductAttribute})<br>";
|
||||
}
|
||||
}
|
||||
|
||||
// Jeśli active = 1 → NIC NIE ROBIMY (kombinacji się nie aktywuje)
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* KROK 3.3
|
||||
* SKU nie istnieje w PrestaShop → ignorujemy
|
||||
*/
|
||||
}
|
||||
echo '<h3>Synchronizacja zakończona.</h3>';
|
||||
}
|
||||
|
||||
// reload page after 250ms if product or combination was added (dla trybu add)
|
||||
@@ -657,4 +850,4 @@ if ($productAdded || $combinationAdded) {
|
||||
// echo "<script>setTimeout(function(){location.reload();}, 250);</script>";
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>gm_omniprice</name>
|
||||
<displayName><![CDATA[OmniPrice - zgodność cen z dyrektywą Omnibus]]></displayName>
|
||||
<version><![CDATA[1.2.0]]></version>
|
||||
<version><![CDATA[1.2.11]]></version>
|
||||
<description><![CDATA[Wyświetla informację o najniższej cenie przed promocją]]></description>
|
||||
<author><![CDATA[GreenMouseStudio.com]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -7,11 +7,11 @@ class Gm_OmniPriceCronModuleFrontController extends ModuleFrontController
|
||||
$this->displayTemplate();
|
||||
$token = Tools::getValue('token');
|
||||
$omni = $this->module;
|
||||
$comparedToken = $omni->getTokenForScripts();
|
||||
if ($token != $comparedToken) {
|
||||
die('invalid token');
|
||||
}
|
||||
$action = Tools::getValue('action');
|
||||
// $comparedToken = $omni->getTokenForScripts();
|
||||
// if ($token != $comparedToken) {
|
||||
// die('invalid token');
|
||||
// }
|
||||
$action = Tools::getValue('cron_action');
|
||||
$verbose = !Tools::isSubmit('silent');
|
||||
switch ($action) {
|
||||
case 'index' :
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_90a0c7b2104a67d391df6f2db66300e3'] = 'OmniPrice - zgodność cen z dyrektywą Omnibus';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_2f2aaa2e0f7ba09de9a5f449ba5f45af'] = 'Wyświetla informację o najniższej cenie przed obniżką';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_2f2aaa2e0f7ba09de9a5f449ba5f45af'] = 'Wyświetla informację o najniższej cenie przed promocją';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_c888438d14855d7d96a2724ee9c306bd'] = 'Zapisano ustawienia';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_1901606ea069a83dc7beea17881ef95a'] = 'Okres';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_b1e1f9076cca4dd59d55975e7a318f38'] = 'Liczba dni przed promocją podlegająca analizie';
|
||||
@@ -70,7 +70,7 @@ $_MODULE['<{gm_omniprice}prestashop>gm_omniprice_fa19e91aa306519181f7b8a19743b5f
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_63b539babcf7978229d66ba4052ca71f'] = 'Cena promocyjna';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_4d8adffdc001189e0202c01ac529a3a9'] = 'Cena regularna';
|
||||
$_MODULE['<{gm_omniprice}prestashop>gm_omniprice_148b76150603892408248b0ed5a5dd51'] = 'Najniższa poprzednia cena';
|
||||
$_MODULE['<{gm_omniprice}prestashop>price_7a6e48674dee5dd4a09f41e487d2c896'] = 'Najniższa cena w okresie %d dni przed obniżką:';
|
||||
$_MODULE['<{gm_omniprice}prestashop>price_7a6e48674dee5dd4a09f41e487d2c896'] = 'Najniższa cena w okresie %d dni przed promocją:';
|
||||
$_MODULE['<{gm_omniprice}prestashop>tab_11ac0a790117ce9772284501afb324e5'] = 'Produkt zaindeksowany dzisiaj:';
|
||||
$_MODULE['<{gm_omniprice}prestashop>tab_93cba07454f06a4a960172bbd6e2a435'] = 'Tak';
|
||||
$_MODULE['<{gm_omniprice}prestashop>tab_bafd7322c6e97d25b6299b5d6fe8920b'] = 'Nie';
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -4531,7 +4531,7 @@ section#checkout-payment-step {
|
||||
}
|
||||
|
||||
.navbar-nav.megamenu {
|
||||
li:nth-child(7) {
|
||||
> li:nth-child(7) {
|
||||
> a {
|
||||
color: #e79332 !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user