update
546
.vscode/ftp-kr.sync.cache.json
vendored
@@ -3458,8 +3458,532 @@
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"config": {},
|
||||
"controllers": {},
|
||||
"config": {
|
||||
"alias.php": {
|
||||
"type": "-",
|
||||
"size": 1971,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"autoload.php": {
|
||||
"type": "-",
|
||||
"size": 1252,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"bootstrap.php": {
|
||||
"type": "-",
|
||||
"size": 6071,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"config.inc.php": {
|
||||
"type": "-",
|
||||
"size": 10015,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"db_slave_server.inc.php": {
|
||||
"type": "-",
|
||||
"size": 1250,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"defines.inc.php": {
|
||||
"type": "-",
|
||||
"size": 6799,
|
||||
"lmtime": 1740602460000,
|
||||
"modified": false
|
||||
},
|
||||
"defines_uri.inc.php": {
|
||||
"type": "-",
|
||||
"size": 3074,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
".htaccess": {
|
||||
"type": "-",
|
||||
"size": 180,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1281,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"services": {},
|
||||
"settings.inc.php": {
|
||||
"type": "-",
|
||||
"size": 23,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"smartyadmin.config.inc.php": {
|
||||
"type": "-",
|
||||
"size": 5846,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"smarty.config.inc.php": {
|
||||
"type": "-",
|
||||
"size": 6860,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"smartyfront.config.inc.php": {
|
||||
"type": "-",
|
||||
"size": 8798,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"smartyfront.config.inc.php.before_pagecache_widget_block": {
|
||||
"type": "-",
|
||||
"size": 8488,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"themes": {},
|
||||
"xml": {}
|
||||
},
|
||||
"controllers": {
|
||||
"admin": {
|
||||
"AdminAccessController.php": {
|
||||
"type": "-",
|
||||
"size": 7689,
|
||||
"lmtime": 1740602640000,
|
||||
"modified": false
|
||||
},
|
||||
"AdminAddressesController.php": {
|
||||
"type": "-",
|
||||
"size": 23125,
|
||||
"lmtime": 1742301706992,
|
||||
"modified": false
|
||||
},
|
||||
"AdminAttachmentsController.php": {
|
||||
"type": "-",
|
||||
"size": 11001,
|
||||
"lmtime": 1742301708067,
|
||||
"modified": false
|
||||
},
|
||||
"AdminAttributeGeneratorController.php": {
|
||||
"type": "-",
|
||||
"size": 11890,
|
||||
"lmtime": 1742301709156,
|
||||
"modified": false
|
||||
},
|
||||
"AdminAttributesGroupsController.php": {
|
||||
"type": "-",
|
||||
"size": 41112,
|
||||
"lmtime": 1742301710261,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCarriersController.php": {
|
||||
"type": "-",
|
||||
"size": 33468,
|
||||
"lmtime": 1742301711413,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCarrierWizardController.php": {
|
||||
"type": "-",
|
||||
"size": 43381,
|
||||
"lmtime": 1742301712505,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCartRulesController.php": {
|
||||
"type": "-",
|
||||
"size": 37832,
|
||||
"lmtime": 1742301713653,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCartsController.php": {
|
||||
"type": "-",
|
||||
"size": 44127,
|
||||
"lmtime": 1742301714807,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCategoriesController.php": {
|
||||
"type": "-",
|
||||
"size": 53593,
|
||||
"lmtime": 1742301715967,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCmsCategoriesController.php": {
|
||||
"type": "-",
|
||||
"size": 16008,
|
||||
"lmtime": 1742301717103,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCmsContentController.php": {
|
||||
"type": "-",
|
||||
"size": 12315,
|
||||
"lmtime": 1742301718179,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCmsController.php": {
|
||||
"type": "-",
|
||||
"size": 21919,
|
||||
"lmtime": 1742301719282,
|
||||
"modified": false
|
||||
},
|
||||
"AdminContactsController.php": {
|
||||
"type": "-",
|
||||
"size": 6037,
|
||||
"lmtime": 1742301720355,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCountriesController.php": {
|
||||
"type": "-",
|
||||
"size": 22794,
|
||||
"lmtime": 1742301721455,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCurrenciesController.php": {
|
||||
"type": "-",
|
||||
"size": 13652,
|
||||
"lmtime": 1742301722595,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCustomersController.php": {
|
||||
"type": "-",
|
||||
"size": 47523,
|
||||
"lmtime": 1742301723708,
|
||||
"modified": false
|
||||
},
|
||||
"AdminCustomerThreadsController.php": {
|
||||
"type": "-",
|
||||
"size": 55796,
|
||||
"lmtime": 1742301724862,
|
||||
"modified": false
|
||||
},
|
||||
"AdminDashboardController.php": {
|
||||
"type": "-",
|
||||
"size": 26319,
|
||||
"lmtime": 1742301726001,
|
||||
"modified": false
|
||||
},
|
||||
"AdminEmployeesController.php": {
|
||||
"type": "-",
|
||||
"size": 28328,
|
||||
"lmtime": 1742301727089,
|
||||
"modified": false
|
||||
},
|
||||
"AdminFeaturesController.php": {
|
||||
"type": "-",
|
||||
"size": 24383,
|
||||
"lmtime": 1742301728176,
|
||||
"modified": false
|
||||
},
|
||||
"AdminGendersController.php": {
|
||||
"type": "-",
|
||||
"size": 8865,
|
||||
"lmtime": 1742301729250,
|
||||
"modified": false
|
||||
},
|
||||
"AdminGroupsController.php": {
|
||||
"type": "-",
|
||||
"size": 26761,
|
||||
"lmtime": 1742301730355,
|
||||
"modified": false
|
||||
},
|
||||
"AdminImagesController.php": {
|
||||
"type": "-",
|
||||
"size": 38981,
|
||||
"lmtime": 1742301731447,
|
||||
"modified": false
|
||||
},
|
||||
"AdminImportController.php": {
|
||||
"type": "-",
|
||||
"size": 243006,
|
||||
"lmtime": 1742301732639,
|
||||
"modified": false
|
||||
},
|
||||
"AdminLanguagesController.php": {
|
||||
"type": "-",
|
||||
"size": 26344,
|
||||
"lmtime": 1742301733747,
|
||||
"modified": false
|
||||
},
|
||||
"AdminLegacyLayoutController.php": {
|
||||
"type": "-",
|
||||
"size": 4238,
|
||||
"lmtime": 1742301734882,
|
||||
"modified": false
|
||||
},
|
||||
"AdminLoginController.php": {
|
||||
"type": "-",
|
||||
"size": 19241,
|
||||
"lmtime": 1742301735983,
|
||||
"modified": false
|
||||
},
|
||||
"AdminManufacturersController.php": {
|
||||
"type": "-",
|
||||
"size": 33545,
|
||||
"lmtime": 1742301737141,
|
||||
"modified": false
|
||||
},
|
||||
"AdminMetaController.php": {
|
||||
"type": "-",
|
||||
"size": 31364,
|
||||
"lmtime": 1742301738295,
|
||||
"modified": false
|
||||
},
|
||||
"AdminModulesController.php": {
|
||||
"type": "-",
|
||||
"size": 78043,
|
||||
"lmtime": 1742301739462,
|
||||
"modified": false
|
||||
},
|
||||
"AdminModulesPositionsController.php": {
|
||||
"type": "-",
|
||||
"size": 30377,
|
||||
"lmtime": 1742301740596,
|
||||
"modified": false
|
||||
},
|
||||
"AdminNotFoundController.php": {
|
||||
"type": "-",
|
||||
"size": 1637,
|
||||
"lmtime": 1742301741731,
|
||||
"modified": false
|
||||
},
|
||||
"AdminOrderMessageController.php": {
|
||||
"type": "-",
|
||||
"size": 3807,
|
||||
"lmtime": 1742301742819,
|
||||
"modified": false
|
||||
},
|
||||
"AdminOrdersController.php": {
|
||||
"type": "-",
|
||||
"size": 165644,
|
||||
"lmtime": 1742301743966,
|
||||
"modified": false
|
||||
},
|
||||
"AdminOutstandingController.php": {
|
||||
"type": "-",
|
||||
"size": 6469,
|
||||
"lmtime": 1742301745571,
|
||||
"modified": false
|
||||
},
|
||||
"AdminPatternsController.php": {
|
||||
"type": "-",
|
||||
"size": 26265,
|
||||
"lmtime": 1742301746673,
|
||||
"modified": false
|
||||
},
|
||||
"AdminPdfController.php": {
|
||||
"type": "-",
|
||||
"size": 8454,
|
||||
"lmtime": 1742301747746,
|
||||
"modified": false
|
||||
},
|
||||
"AdminPreferencesController.php": {
|
||||
"type": "-",
|
||||
"size": 13671,
|
||||
"lmtime": 1742301748835,
|
||||
"modified": false
|
||||
},
|
||||
"AdminProductsController.php": {
|
||||
"type": "-",
|
||||
"size": 154830,
|
||||
"lmtime": 1742301749975,
|
||||
"modified": false
|
||||
},
|
||||
"AdminProfilesController.php": {
|
||||
"type": "-",
|
||||
"size": 4269,
|
||||
"lmtime": 1742301751075,
|
||||
"modified": false
|
||||
},
|
||||
"AdminQuickAccessesController.php": {
|
||||
"type": "-",
|
||||
"size": 9904,
|
||||
"lmtime": 1742301752163,
|
||||
"modified": false
|
||||
},
|
||||
"AdminReferrersController.php": {
|
||||
"type": "-",
|
||||
"size": 22750,
|
||||
"lmtime": 1742301753266,
|
||||
"modified": false
|
||||
},
|
||||
"AdminRequestSqlController.php": {
|
||||
"type": "-",
|
||||
"size": 21496,
|
||||
"lmtime": 1742301754354,
|
||||
"modified": false
|
||||
},
|
||||
"AdminReturnController.php": {
|
||||
"type": "-",
|
||||
"size": 15152,
|
||||
"lmtime": 1742301755427,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSearchConfController.php": {
|
||||
"type": "-",
|
||||
"size": 19832,
|
||||
"lmtime": 1742301756529,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSearchController.php": {
|
||||
"type": "-",
|
||||
"size": 22528,
|
||||
"lmtime": 1742301757617,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSearchEnginesController.php": {
|
||||
"type": "-",
|
||||
"size": 3679,
|
||||
"lmtime": 1742301758690,
|
||||
"modified": false
|
||||
},
|
||||
"AdminShopController.php": {
|
||||
"type": "-",
|
||||
"size": 37822,
|
||||
"lmtime": 1742301759796,
|
||||
"modified": false
|
||||
},
|
||||
"AdminShopGroupController.php": {
|
||||
"type": "-",
|
||||
"size": 15148,
|
||||
"lmtime": 1742301760867,
|
||||
"modified": false
|
||||
},
|
||||
"AdminShopUrlController.php": {
|
||||
"type": "-",
|
||||
"size": 24841,
|
||||
"lmtime": 1742301761970,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSlipController.php": {
|
||||
"type": "-",
|
||||
"size": 7594,
|
||||
"lmtime": 1742301763106,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSpecificPriceRuleController.php": {
|
||||
"type": "-",
|
||||
"size": 16441,
|
||||
"lmtime": 1742301764207,
|
||||
"modified": false
|
||||
},
|
||||
"AdminStatesController.php": {
|
||||
"type": "-",
|
||||
"size": 13161,
|
||||
"lmtime": 1742301765283,
|
||||
"modified": false
|
||||
},
|
||||
"AdminStatsController.php": {
|
||||
"type": "-",
|
||||
"size": 40696,
|
||||
"lmtime": 1742301766391,
|
||||
"modified": false
|
||||
},
|
||||
"AdminStatsTabController.php": {
|
||||
"type": "-",
|
||||
"size": 11896,
|
||||
"lmtime": 1742301767523,
|
||||
"modified": false
|
||||
},
|
||||
"AdminStatusesController.php": {
|
||||
"type": "-",
|
||||
"size": 29123,
|
||||
"lmtime": 1742301768754,
|
||||
"modified": false
|
||||
},
|
||||
"AdminStoresController.php": {
|
||||
"type": "-",
|
||||
"size": 25706,
|
||||
"lmtime": 1742301769848,
|
||||
"modified": false
|
||||
},
|
||||
"AdminSuppliersController.php": {
|
||||
"type": "-",
|
||||
"size": 23926,
|
||||
"lmtime": 1742301770993,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTabsController.php": {
|
||||
"type": "-",
|
||||
"size": 14703,
|
||||
"lmtime": 1742301772066,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTagsController.php": {
|
||||
"type": "-",
|
||||
"size": 5712,
|
||||
"lmtime": 1742301773154,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTaxesController.php": {
|
||||
"type": "-",
|
||||
"size": 13593,
|
||||
"lmtime": 1742301774242,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTaxRulesGroupController.php": {
|
||||
"type": "-",
|
||||
"size": 23014,
|
||||
"lmtime": 1742301775348,
|
||||
"modified": false
|
||||
},
|
||||
"AdminThemesController.php": {
|
||||
"type": "-",
|
||||
"size": 44040,
|
||||
"lmtime": 1742301776631,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTrackingController.php": {
|
||||
"type": "-",
|
||||
"size": 19268,
|
||||
"lmtime": 1742301777775,
|
||||
"modified": false
|
||||
},
|
||||
"AdminTranslationsController.php": {
|
||||
"type": "-",
|
||||
"size": 153026,
|
||||
"lmtime": 1742301778902,
|
||||
"modified": false
|
||||
},
|
||||
"AdminWebserviceController.php": {
|
||||
"type": "-",
|
||||
"size": 12558,
|
||||
"lmtime": 1742301780004,
|
||||
"modified": false
|
||||
},
|
||||
"AdminZonesController.php": {
|
||||
"type": "-",
|
||||
"size": 5030,
|
||||
"lmtime": 1742301781090,
|
||||
"modified": false
|
||||
},
|
||||
"BoOrder.php": {
|
||||
"type": "-",
|
||||
"size": 1242,
|
||||
"lmtime": 1742301782180,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1288,
|
||||
"lmtime": 1742301783266,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"front": {},
|
||||
".htaccess": {
|
||||
"type": "-",
|
||||
"size": 180,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1285,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"cron-estella.php": {
|
||||
"type": "-",
|
||||
"size": 2399,
|
||||
@@ -3512,13 +4036,13 @@
|
||||
},
|
||||
"google-merchant_id-1.xml": {
|
||||
"type": "-",
|
||||
"size": 73443780,
|
||||
"size": 73827768,
|
||||
"lmtime": 0,
|
||||
"modified": true
|
||||
},
|
||||
"google-merchant_id-2.xml": {
|
||||
"type": "-",
|
||||
"size": 2974603,
|
||||
"size": 2956284,
|
||||
"lmtime": 0,
|
||||
"modified": true
|
||||
},
|
||||
@@ -3587,6 +4111,12 @@
|
||||
},
|
||||
"localization": {},
|
||||
"logs": {},
|
||||
"lulandia.tar.gz": {
|
||||
"type": "-",
|
||||
"size": 9825117591,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"mails": {},
|
||||
"modules": {},
|
||||
"nov": {},
|
||||
@@ -4138,14 +4668,14 @@
|
||||
},
|
||||
"theme.css.map": {
|
||||
"type": "-",
|
||||
"size": 1362237,
|
||||
"lmtime": 1741161153795,
|
||||
"size": 147127,
|
||||
"lmtime": 1742304582226,
|
||||
"modified": false
|
||||
},
|
||||
"theme.scss": {
|
||||
"type": "-",
|
||||
"size": 640864,
|
||||
"lmtime": 1741161153983,
|
||||
"size": 625079,
|
||||
"lmtime": 1742304582234,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
|
||||
582
import-product.php
Normal file
@@ -0,0 +1,582 @@
|
||||
<?php
|
||||
// Dołącz plik konfiguracyjny PrestaShop
|
||||
include(dirname(__FILE__) . '/config/config.inc.php');
|
||||
include(dirname(__FILE__) . '/init.php');
|
||||
|
||||
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
|
||||
use PrestaShop\PrestaShop\Adapter\Entity\Product;
|
||||
|
||||
// ID sklepu, dla którego mają być aktualizowane produkty
|
||||
$id_shop = 2;
|
||||
|
||||
// Pobierz produkty, których nazwa zawiera "AMZ" i należą do sklepu o id_shop = 2
|
||||
$sql = new DbQuery();
|
||||
$sql->select('p.id_product');
|
||||
$sql->from('product', 'p');
|
||||
$sql->innerJoin('product_shop', 'ps', 'p.id_product = ps.id_product');
|
||||
$sql->innerJoin('product_lang', 'pl', 'p.id_product = pl.id_product AND pl.id_shop = ps.id_shop');
|
||||
$sql->where("pl.name LIKE '%AMZ%'");
|
||||
$sql->where("ps.id_shop = $id_shop");
|
||||
$sql->groupBy("p.id_product");
|
||||
|
||||
$products = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (!$products) {
|
||||
echo "Nie znaleziono produktów zawierających 'AMZ' w nazwie dla sklepu ID $id_shop.";
|
||||
exit;
|
||||
}
|
||||
echo count( $products ) . " produktów do aktualizacji.\n";
|
||||
|
||||
foreach ($products as $product) {
|
||||
$id_product = (int) $product['id_product'];
|
||||
|
||||
// Zaktualizuj wartość out_of_stock na 2 tylko dla id_shop = 2
|
||||
$updateSql = "UPDATE " . _DB_PREFIX_ . "stock_available
|
||||
SET out_of_stock = 2
|
||||
WHERE id_product = $id_product AND id_shop = $id_shop";
|
||||
|
||||
Db::getInstance()->execute($updateSql);
|
||||
echo "Zaktualizowano produkt ID $id_product: out_of_stock ustawione na 2.\n";
|
||||
}
|
||||
|
||||
echo "Aktualizacja zakończona. Wszystkie produkty z 'AMZ' w nazwie mają ustawione out_of_stock na 2 dla sklepu ID $id_shop.";
|
||||
|
||||
?>
|
||||
|
||||
// https://pacyga.pl/wp-content/uploads/woo-feed/custom/xml/komplet-produktow-3.xml
|
||||
// Include PrestaShop configuration
|
||||
// $config['update_price'] = false;
|
||||
// include(dirname(__FILE__).'/config/config.inc.php');
|
||||
// include(dirname(__FILE__).'/init.php');
|
||||
|
||||
// // Load XML file
|
||||
// $xml = simplexml_load_file('https://cdn.projectpro.pl/drmaterac.pl/produkty-amz.xml') or die("Error: Cannot create object");
|
||||
|
||||
// // Logowanie czasu wykonania
|
||||
// function logTime($message, $startTime) {
|
||||
// file_put_contents('import_log.txt', $message . ' - Czas: ' . round(microtime(true) - $startTime, 10) . " s\n", FILE_APPEND);
|
||||
// }
|
||||
|
||||
// $startGlobal = microtime(true);
|
||||
|
||||
// // Function to find attribute group by name
|
||||
// function findAttributeGroupByName($name) {
|
||||
// $id_lang = Context::getContext()->language->id;
|
||||
// $result = Db::getInstance()->getRow('SELECT `id_attribute_group` FROM `'._DB_PREFIX_.'attribute_group_lang` WHERE `name` = \''.pSQL($name).'\' AND `id_lang` = '.(int)$id_lang);
|
||||
// return $result ? new AttributeGroup($result['id_attribute_group']) : false;
|
||||
// }
|
||||
|
||||
// // Function to find attribute by name
|
||||
// function findAttributeByName($id_attribute_group, $name) {
|
||||
// $id_lang = Context::getContext()->language->id;
|
||||
// $sql = 'SELECT a.`id_attribute`
|
||||
// FROM `'._DB_PREFIX_.'attribute` a
|
||||
// JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
|
||||
// WHERE al.`name` = \''.pSQL($name).'\' AND al.`id_lang` = '.(int)$id_lang.' AND a.`id_attribute_group` = '.(int)$id_attribute_group;
|
||||
// $result = Db::getInstance()->getRow($sql);
|
||||
// return $result ? new Attribute($result['id_attribute']) : false;
|
||||
// }
|
||||
|
||||
// // Function to check if a product already has images
|
||||
// function productHasImages($productId) {
|
||||
// $images = Image::getImages(Context::getContext()->language->id, $productId);
|
||||
// return !empty($images);
|
||||
// }
|
||||
|
||||
// // Function to create attribute if it doesn't exist
|
||||
// function createAttribute($name, $values) {
|
||||
// $attributeGroup = findAttributeGroupByName($name);
|
||||
// if (!$attributeGroup) {
|
||||
// $attributeGroup = new AttributeGroup();
|
||||
// $attributeGroup->name = createMultiLangField($name);
|
||||
// $attributeGroup->public_name = createMultiLangField($name);
|
||||
// $attributeGroup->group_type = 'select';
|
||||
// $attributeGroup->add();
|
||||
// }
|
||||
|
||||
// foreach ($values as $value) {
|
||||
// $attribute = findAttributeByName($attributeGroup->id, $value);
|
||||
// if (!$attribute) {
|
||||
// $attribute = new Attribute();
|
||||
// $attribute->id_attribute_group = $attributeGroup->id;
|
||||
// $attribute->name = createMultiLangField($value);
|
||||
// $attribute->add();
|
||||
// }
|
||||
// }
|
||||
|
||||
// return $attributeGroup->id;
|
||||
// }
|
||||
|
||||
// // Helper function to create a multi-language field
|
||||
// function createMultiLangField($field) {
|
||||
// $languages = Language::getLanguages(false);
|
||||
// $res = [];
|
||||
// foreach ($languages as $lang) {
|
||||
// $res[$lang['id_lang']] = $field;
|
||||
// }
|
||||
// return $res;
|
||||
// }
|
||||
|
||||
// // Helper function to create a valid link_rewrite
|
||||
// function createLinkRewrite($field) {
|
||||
// $languages = Language::getLanguages(false);
|
||||
// $res = [];
|
||||
// $linkRewrite = Tools::link_rewrite($field); // PrestaShop's function to create valid link_rewrite
|
||||
// foreach ($languages as $lang) {
|
||||
// $res[$lang['id_lang']] = $linkRewrite;
|
||||
// }
|
||||
// return $res;
|
||||
// }
|
||||
|
||||
// // Function to get category ID from name
|
||||
// function getCategoryId($categoryName) {
|
||||
// $category = Category::searchByName(1, $categoryName); // 1 for default language id
|
||||
// if (!empty($category)) {
|
||||
// return $category['id_category'];
|
||||
// } else {
|
||||
// // Create category if not exists
|
||||
// $category = new Category();
|
||||
// $category->name = createMultiLangField($categoryName);
|
||||
// $category->link_rewrite = createLinkRewrite($categoryName);
|
||||
// $category->id_parent = 2; // Default parent category
|
||||
// $category->add();
|
||||
// return $category->id;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Function to log added images
|
||||
// function logAddedImage($productId, $imageUrl) {
|
||||
// $logFile = dirname(__FILE__) . '/image_log.json';
|
||||
// $logData = file_exists($logFile) ? json_decode(file_get_contents($logFile), true) : [];
|
||||
// if (!isset($logData[$productId])) {
|
||||
// $logData[$productId] = [];
|
||||
// }
|
||||
// $logData[$productId][] = $imageUrl;
|
||||
// file_put_contents($logFile, json_encode($logData));
|
||||
// }
|
||||
|
||||
// // Function to check if an image has been added
|
||||
// function isImageAdded($productId, $imageUrl) {
|
||||
// $logFile = dirname(__FILE__) . '/image_log.json';
|
||||
// if (!file_exists($logFile)) {
|
||||
// return false;
|
||||
// }
|
||||
// $logData = json_decode(file_get_contents($logFile), true);
|
||||
// return isset($logData[$productId]) && in_array($imageUrl, $logData[$productId]);
|
||||
// }
|
||||
|
||||
// // Function to download image from URL and associate it with a product
|
||||
// function addProductImage($productId, $imageUrl) {
|
||||
// // if (isImageAdded($productId, $imageUrl)) {
|
||||
// // return false; // Skip duplicate images
|
||||
// // }
|
||||
|
||||
// $image = new Image();
|
||||
// $image->id_product = $productId;
|
||||
// $image->position = Image::getHighestPosition($productId) + 1;
|
||||
// $image->add();
|
||||
|
||||
// $imagePath = $image->getPathForCreation();
|
||||
// $url = str_replace(' ', '%20', $imageUrl);
|
||||
// if (!copy($url, $imagePath . '.jpg')) {
|
||||
// $image->delete();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// $imageTypes = ImageType::getImagesTypes('products');
|
||||
// foreach ($imageTypes as $imageType) {
|
||||
// ImageManager::resize($imagePath . '.jpg', $imagePath . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']);
|
||||
// }
|
||||
|
||||
// logAddedImage($productId, $imageUrl);
|
||||
// return $image->id;
|
||||
// }
|
||||
|
||||
// // Function to set the first image as cover
|
||||
// function setCoverImage($productId) {
|
||||
// $images = Image::getImages(Context::getContext()->language->id, $productId);
|
||||
// if (!empty($images)) {
|
||||
// $firstImage = reset($images);
|
||||
// $firstImageId = $firstImage['id_image'];
|
||||
// Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'image` SET cover = 0 WHERE id_product = '.(int)$productId);
|
||||
// Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'image` SET cover = 1 WHERE id_image = '.(int)$firstImageId);
|
||||
// Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'image_shop` SET cover = 0 WHERE id_product = '.(int)$productId);
|
||||
// Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'image_shop` SET cover = 1 WHERE id_image = '.(int)$firstImageId);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Function to find product by reference
|
||||
// function findProductByReference($reference) {
|
||||
// $result = Db::getInstance()->getRow('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `reference` = \''.pSQL($reference).'\'');
|
||||
// return $result ? new Product($result['id_product']) : false;
|
||||
// }
|
||||
|
||||
// // Function to find combination by product ID and attribute IDs
|
||||
// function findCombinationByAttributes($id_product, $attributeIds) {
|
||||
// sort($attributeIds);
|
||||
// $sql = 'SELECT c.`id_product_attribute`
|
||||
// FROM `'._DB_PREFIX_.'product_attribute` c
|
||||
// JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON c.`id_product_attribute` = pac.`id_product_attribute`
|
||||
// WHERE c.`id_product` = '.(int)$id_product.'
|
||||
// GROUP BY c.`id_product_attribute`
|
||||
// HAVING SUM(pac.`id_attribute` = '.implode(' OR pac.`id_attribute` = ', array_map('intval', $attributeIds)).') = '.count($attributeIds);
|
||||
// $result = Db::getInstance()->getRow($sql);
|
||||
// return $result ? new Combination($result['id_product_attribute']) : false;
|
||||
// }
|
||||
|
||||
// // Function to assign manufacturer to product
|
||||
// function assignManufacturerToProduct($productId, $manufacturerId) {
|
||||
// $product = new Product($productId);
|
||||
// $product->id_manufacturer = $manufacturerId;
|
||||
// $product->update();
|
||||
// }
|
||||
|
||||
// // Function to assign feature to product (without searching for IDs)
|
||||
// function assignFeatureToProduct($productId, $featureId, $featureValueId) {
|
||||
// $existingFeature = Db::getInstance()->getRow(
|
||||
// 'SELECT id_feature_product FROM `'._DB_PREFIX_.'feature_product` WHERE `id_product` = '.(int)$productId.' AND `id_feature` = '.(int)$featureId
|
||||
// );
|
||||
|
||||
// if (!$existingFeature) {
|
||||
// Db::getInstance()->insert('feature_product', [
|
||||
// 'id_product' => (int)$productId,
|
||||
// 'id_feature' => (int)$featureId,
|
||||
// 'id_feature_value' => (int)$featureValueId
|
||||
// ]);
|
||||
// } else {
|
||||
// Db::getInstance()->update('feature_product', [
|
||||
// 'id_feature_value' => (int)$featureValueId
|
||||
// ], 'id_feature_product = '.(int)$existingFeature['id_feature_product']);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Function to update additional delivery parameters
|
||||
// function updateDeliveryParameters($productId) {
|
||||
// $product = new Product($productId);
|
||||
// $product->additional_delivery_times = 2;
|
||||
// $product->delivery_in_stock = 'ok. 2-5 dni roboczych';
|
||||
// $product->delivery_out_stock = 'ok. 2-5 dni roboczych';
|
||||
// $product->update();
|
||||
// }
|
||||
|
||||
// // Function to calculate combination price impact
|
||||
// function calculatePriceImpact($basePrice, $combinationPrice) {
|
||||
// return floatval(str_replace(',', '', $combinationPrice)) - floatval(str_replace(',', '', $basePrice));
|
||||
// }
|
||||
|
||||
// function addProductToShops($product) {
|
||||
// $shops = [1, 2];
|
||||
// foreach ($shops as $shopId) {
|
||||
// Db::getInstance()->execute('INSERT IGNORE INTO `'._DB_PREFIX_.'product_shop` (`id_product`, `id_shop`, `id_category_default`, `price`, `active`)
|
||||
// VALUES ('.(int)$product->id.', '.(int)$shopId.', 2, '.(float)$product->price.', 1)');
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Funkcja do przypisania kombinacji do obu sklepów
|
||||
// function addCombinationToShops($combination) {
|
||||
// $shops = [1, 2];
|
||||
// foreach ($shops as $shopId) {
|
||||
// Db::getInstance()->execute('INSERT IGNORE INTO `'._DB_PREFIX_.'product_attribute_shop` (`id_product_attribute`, `id_product`, `id_shop`, `price`)
|
||||
// VALUES ('.(int)$combination->id.', '.(int)$combination->id_product.', '.(int)$shopId.', '.(float)$combination->price.')');
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Funkcja do dodawania obrazów do obu sklepów
|
||||
// function addImageToShops($imageId, $productId) {
|
||||
// $shops = [1, 2];
|
||||
// foreach ($shops as $shopId) {
|
||||
// Db::getInstance()->execute('INSERT IGNORE INTO `'._DB_PREFIX_.'image_shop` (`id_image`, `id_product`, `id_shop`, `cover`)
|
||||
// VALUES ('.(int)$imageId.', '.(int)$productId.', '.(int)$shopId.', 0)');
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Function to parse and import product features
|
||||
// function importProductFeatures($productId, $featuresString) {
|
||||
// $features = explode('|', $featuresString);
|
||||
// foreach ($features as $feature) {
|
||||
// list($featureName, $featureValue) = explode('>', $feature, 2);
|
||||
|
||||
// if ( trim( $featureValue ) == 'Rozmiar' or $featureValue == 'ROZMIAR' or strpos( $featureName, 'filtr rozwijany' ) !== false )
|
||||
// continue;
|
||||
|
||||
// $featureName = trim($featureName);
|
||||
// $featureValue = trim($featureValue);
|
||||
|
||||
// $featureId = Db::getInstance()->getValue(
|
||||
// 'SELECT id_feature FROM `'._DB_PREFIX_.'feature_lang` WHERE name = "' . pSQL($featureName) . '"'
|
||||
// );
|
||||
|
||||
// if (!$featureId) {
|
||||
// $feature = new Feature();
|
||||
// $feature->name = createMultiLangField($featureName);
|
||||
// $feature->add();
|
||||
// $featureId = $feature->id;
|
||||
// }
|
||||
|
||||
// if ( $featureId == 47 or $featureId == 76 )
|
||||
// continue;
|
||||
|
||||
// $featureValueId = Db::getInstance()->getValue(
|
||||
// 'SELECT fv.id_feature_value FROM `'._DB_PREFIX_.'feature_value` fv
|
||||
// JOIN `'._DB_PREFIX_.'feature_value_lang` fvl ON fv.id_feature_value = fvl.id_feature_value
|
||||
// WHERE fvl.value = "' . pSQL($featureValue) . '" AND fv.id_feature = ' . (int)$featureId
|
||||
// );
|
||||
|
||||
// if (!$featureValueId) {
|
||||
// $featureValueObj = new FeatureValue();
|
||||
// $featureValueObj->id_feature = $featureId;
|
||||
// $featureValueObj->value = createMultiLangField($featureValue);
|
||||
// $featureValueObj->add();
|
||||
// $featureValueId = $featureValueObj->id;
|
||||
// }
|
||||
|
||||
// Db::getInstance()->insert('feature_product', [
|
||||
// 'id_product' => (int)$productId,
|
||||
// 'id_feature' => (int)$featureId,
|
||||
// 'id_feature_value' => (int)$featureValueId
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Parse XML and group products by Symbol
|
||||
// $productsBySymbol = [];
|
||||
// foreach ( $xml -> post as $productData )
|
||||
// {
|
||||
// $i = 1;
|
||||
// $product_tmp = (array)$productData;
|
||||
|
||||
// $Dostępnerozmiaryjeślidotyczy = $product_tmp['Dostępnerozmiaryjeślidotyczy:untitled_3'];
|
||||
// $sku = $product_tmp['KodEAN-13'];
|
||||
// $title = $product_tmp['Nazwaproduktu'] . ' AMZ';
|
||||
// $description = $product_tmp['Długiopis'];
|
||||
// $short_description = $product_tmp['Krótkiopis'];
|
||||
// $price = $product_tmp['CenaBRUTTO'];
|
||||
// $rozmiar = $product_tmp['Dostępnerozmiaryjeślidotyczy:untitled_3'];
|
||||
// $kolor = $product_tmp['Dostępnekoloryjeślidotyczy:untitled_2'];
|
||||
|
||||
// $images = explode( '|', $product_tmp['ZdjęciaproduktuURL-e'] );
|
||||
|
||||
// if ( !count( $images ) or ( count( $images ) == 1 and empty( $images[0] ) ) )
|
||||
// {
|
||||
// if ( isset( $product_images[ $symbol ]['images'] ) )
|
||||
// $images = $product_images[ $symbol ]['images'];
|
||||
// }
|
||||
|
||||
// foreach ( $images as $image )
|
||||
// {
|
||||
// $productData->{'images_' . $i} = $image;
|
||||
// $i++;
|
||||
// }
|
||||
|
||||
// $symbol = md5( $productData -> Nazwaproduktu );
|
||||
|
||||
// $productData->sku = $sku;
|
||||
// $productData->title = $title;
|
||||
// $productData->description = $description;
|
||||
// $productData->short_description = $short_description;
|
||||
// $productData->price = $price;
|
||||
// $productData->rozmiar = $rozmiar;
|
||||
// $productData->kolor = $kolor;
|
||||
|
||||
// if ( !isset( $productsBySymbol[$symbol] ) ) {
|
||||
// $productsBySymbol[$symbol] = [];
|
||||
// }
|
||||
|
||||
// if ( strpos( $Dostępnerozmiaryjeślidotyczy, '|' ) === false )
|
||||
// $productsBySymbol[$symbol][] = $productData;
|
||||
// else
|
||||
// {
|
||||
// $product_images[ $symbol ]['images'] = $images;
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach ($productsBySymbol as $symbol => $products)
|
||||
// {
|
||||
// if ( empty( $products ) ) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// $mainProductData = $products[0];
|
||||
// $mainProduct = findProductByReference((string)$mainProductData->sku);
|
||||
|
||||
// $productAdded = false;
|
||||
// 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);
|
||||
// $mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
|
||||
// $mainProduct->reference = (string)$mainProductData->sku;
|
||||
// $mainProduct->id_category_default = 2;
|
||||
// $mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
|
||||
// $mainProduct->id_shop_list = [1, 2]; // Przypisanie do sklepów
|
||||
// $mainProduct->add();
|
||||
|
||||
// addProductToShops($mainProduct);
|
||||
|
||||
// if (!empty($mainProductData->Cechyproduktu)) {
|
||||
// importProductFeatures($mainProduct->id, (string)$mainProductData->Cechyproduktu);
|
||||
// }
|
||||
|
||||
// // Ensure the product has combinations enabled
|
||||
// $mainProduct->checkDefaultAttributes();
|
||||
|
||||
// Product::updateDefaultAttribute($mainProduct->id);
|
||||
// assignFeatureToProduct($mainProduct->id, 41, 2499);
|
||||
// assignManufacturerToProduct($mainProduct->id, 53);
|
||||
// updateDeliveryParameters($mainProduct->id);
|
||||
|
||||
// $productAdded = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if ( $config['update_price'] == true )
|
||||
// {
|
||||
// $mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
|
||||
// $description = (string)$mainProductData->description;
|
||||
// $description = str_replace("\n", "<br>", $description);
|
||||
// $mainProduct->description = createMultiLangField($description);
|
||||
// $mainProduct->update();
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Ensure the product is saved before adding combinations
|
||||
// if (!$mainProduct->id) {
|
||||
// echo "Failed to create or update main product: " . (string)$mainProductData->title . "\n";
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // Ensure the combination set is unique for the product
|
||||
// $addedCombinations = [];
|
||||
|
||||
// // Add or update combinations for each product in the group
|
||||
// $combinationAdded = false;
|
||||
// foreach ($products as $productData)
|
||||
// {
|
||||
// $attributes = [
|
||||
// 'Kolor' => (string)$productData->kolor,
|
||||
// 'Rozmiar' => (string)$productData->rozmiar
|
||||
// ];
|
||||
|
||||
// $attributeIds = [];
|
||||
// foreach ($attributes as $name => $value) {
|
||||
// if (!empty($value)) {
|
||||
// $attributeGroupId = createAttribute($name, [$value]);
|
||||
// $attribute = findAttributeByName($attributeGroupId, $value);
|
||||
// if ($attribute) {
|
||||
// $attributeIds[] = $attribute->id;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Create a unique key for the attribute set
|
||||
// sort($attributeIds);
|
||||
// $key = implode('-', $attributeIds);
|
||||
|
||||
// // Add or update combination if it is unique
|
||||
// if (!empty($attributeIds))
|
||||
// {
|
||||
// $combination = findCombinationByAttributes($mainProduct->id, $attributeIds);
|
||||
|
||||
// if (!$combination) {
|
||||
// // Create new combination
|
||||
// $combination = new Combination();
|
||||
// $combination->id_product = $mainProduct->id;
|
||||
// $combination->quantity = 100; // Default quantity, you can adjust this
|
||||
// $combination->reference = (string)$productData->sku;
|
||||
// $combination->price = calculatePriceImpact($mainProductData->price, $productData->price);
|
||||
// $combination->add();
|
||||
// $combination->setAttributes($attributeIds);
|
||||
// $combination->save();
|
||||
|
||||
// addCombinationToShops($combination);
|
||||
|
||||
// $combinationAdded = true;
|
||||
// } else {
|
||||
// // Update existing combination quantity if necessary
|
||||
// $combination->quantity = 100; // Update quantity, you can adjust this
|
||||
// $combination->update();
|
||||
// }
|
||||
|
||||
// // Mark this combination as added
|
||||
// $addedCombinations[$key] = true;
|
||||
// }
|
||||
|
||||
// if ( $combinationAdded )
|
||||
// {
|
||||
// if ( !productHasImages($mainProduct->id) and !empty($productData->images_2) )
|
||||
// {
|
||||
// for ($i = 1; $i <= 10; $i++) {
|
||||
// $imageUrl = (string)$productData->{'images_' . $i};
|
||||
// if (!empty($imageUrl)) {
|
||||
// $imageId = addProductImage($mainProduct->id, $imageUrl);
|
||||
// if ($imageId) {
|
||||
// addImageToShops($imageId, $mainProduct->id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// setCoverImage($mainProduct->id);
|
||||
|
||||
// break; // Break if a new combination was added
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($productAdded || $combinationAdded) {
|
||||
// if ($productAdded) {
|
||||
// echo "<p>Dodałem produkt: " . (string)$mainProductData->title . "</p>";
|
||||
// }
|
||||
// if ($combinationAdded) {
|
||||
// echo "<p>Dodałem kombinację: " . (string)$mainProductData->title . "</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>";
|
||||
// }
|
||||
|
||||
require_once dirname(__FILE__) . '/config/config.inc.php';
|
||||
require_once dirname(__FILE__) . '/init.php';
|
||||
|
||||
// Pobranie ID produktów zawierających "AMZ" w nazwie i bez uzupełnionego EAN
|
||||
$products = Db::getInstance()->executeS(
|
||||
'SELECT p.id_product FROM ' . _DB_PREFIX_ . 'product p
|
||||
JOIN ' . _DB_PREFIX_ . 'product_lang pl ON p.id_product = pl.id_product
|
||||
WHERE pl.name LIKE "%AMZ%"'
|
||||
);
|
||||
|
||||
if (!$products) {
|
||||
die('Nie znaleziono produktów zawierających "AMZ".');
|
||||
}
|
||||
|
||||
foreach ($products as $product) {
|
||||
$id_product = (int)$product['id_product'];
|
||||
|
||||
// Pobranie kombinacji produktu bez uzupełnionego EAN
|
||||
$combinations = Db::getInstance()->executeS(
|
||||
'SELECT id_product_attribute, reference FROM ' . _DB_PREFIX_ . 'product_attribute
|
||||
WHERE id_product = ' . $id_product . ' AND (ean13 IS NULL OR ean13 = "")'
|
||||
);
|
||||
|
||||
if (!$combinations) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($combinations as $combination) {
|
||||
$id_product_attribute = (int)$combination['id_product_attribute'];
|
||||
$sku = pSQL($combination['reference']); // SKU
|
||||
|
||||
// Aktualizacja pola EAN (wstawienie wartości SKU)
|
||||
Db::getInstance()->execute(
|
||||
'UPDATE ' . _DB_PREFIX_ . 'product_attribute SET ean13 = "' . $sku . '" WHERE id_product_attribute = ' . $id_product_attribute
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Zaktualizowano SKU do EAN dla wszystkich odpowiednich kombinacji produktów zawierających "AMZ" w nazwie.';
|
||||
?>
|
||||
22
script.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
include 'modules/medoo.php';
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => '32887222_5ff13557',
|
||||
'server' => '127.0.0.1',
|
||||
'username' => '32887222_5ff13557',
|
||||
'password' => '8mhqV9Rh',
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
$results = $mdb -> select( 'materac_category', 'id_category' );
|
||||
if ( $results ) {
|
||||
echo '[';
|
||||
foreach ( $results as $row ) {
|
||||
echo $row;
|
||||
if ( $row != end ( $results ) )
|
||||
echo ',';
|
||||
}
|
||||
echo ']';
|
||||
}
|
||||
|
Before Width: | Height: | Size: 242 KiB |
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 505 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 47 KiB |