* @copyright 2007-2021 MEG Venture * @license For Prestashop--> http://opensource.org/licenses/osl-3.2.1.php Open Software License (OSL 3.2.1) * * This program is not a free software: you can't redistribute it and/or modify * it. All rights reserved to MEG Venture. * * This copyright notice and licence should be retained in all modules based on this framework. * This does not affect your rights to assert copyright over your own original work. */ include dirname(__FILE__) . '/../../../../config/config.inc.php'; include_once dirname(__FILE__) . '/../../../../init.php'; Db::getInstance()->delete('squaremeteradmin', 'id_shop < 32'); $allshops = Shop::getShops(); foreach ($allshops as $shop) { $sql = 'INSERT INTO `' . pSQL(_DB_PREFIX_) . 'squaremeteradmin` (`id_product`) SELECT `id_product` FROM `' . pSQL(_DB_PREFIX_) . 'product` e WHERE NOT EXISTS (SELECT * FROM `' . pSQL(_DB_PREFIX_) . 'squaremeteradmin` WHERE id_product = e.id_product AND id_shop = ' . $shop["id_shop"] . ')'; Db::getInstance()->Execute($sql); $sql = 'UPDATE `' . pSQL(_DB_PREFIX_) . 'squaremeteradmin` SET `id_shop` = ' . $shop["id_shop"] . ' WHERE `id_shop` = 0'; Db::getInstance()->Execute($sql); } $csv_file = $_FILES['csv_file']['tmp_name']; if (is_file($csv_file)) { $input = fopen($csv_file, 'a+'); /* if the csv file contain the table header leave this line */ $row = fgetcsv($input, 0, ','); /* here you got the header */ while ($row = fgetcsv($input, 0, ',')) { /* insert into the database */ $sucs = Db::getInstance()->Execute('UPDATE ' . pSQL(_DB_PREFIX_) . 'squaremeteradmin SET `displaycalculator` = "' . pSQL($row[2]) . '", `displaypicture` = "' . pSQL($row[3]) . '", `calculationtype` = "' . pSQL($row[4]) . '", `additionalquantity` = "' . pSQL($row[5]) . '", `directinput` = "' . pSQL($row[6]) . '", `displayquantity` = "' . pSQL($row[7]) . '", `ratio` = "' . pSQL($row[39]) . '", `displayprice` = "' . pSQL($row[8]) . '", `displayreserve` = "' . pSQL($row[9]) . '", `unit_baseprice` = "' . pSQL($row[10]) . '", `displaystartingprice` = "' . pSQL($row[11]) . '", `displayextrafee` = "' . pSQL($row[12]) . '", `displayextrafeeselect` = "' . pSQL($row[13]) . '", `displaywaste` = "' . pSQL($row[14]) . '", `displaywasteselect` = "' . pSQL($row[15]) . '", `conversion` = "' . pSQL($row[16]) . '", `secconversionselect` = "' . pSQL($row[17]) . '", `secconversion` = "' . pSQL($row[18]) . '", `conversionunit` = "' . pSQL($row[19]) . '", `attribute` = "' . pSQL($row[20]) . '", `attributeunit` = "' . pSQL($row[21]) . '", `step` = "' . pSQL($row[22]) . '", `disableapplet` = "' . pSQL($row[23]) . '", `allow_ordering_from_listing` = "' . pSQL($row[24]) . '", `attselect` = "' . pSQL($row[25]) . '", `minheight` = "' . pSQL($row[26]) . '", `maxheight` = "' . pSQL($row[27]) . '", `maxheightunit` = "' . pSQL($row[28]) . '", `heightcheck` = "' . pSQL($row[29]) . '", `step_height` = "' . pSQL($row[30]) . '", `minwidth` = "' . pSQL($row[31]) . '", `maxwidth` = "' . pSQL($row[32]) . '", `maxwidthunit` = "' . pSQL($row[33]) . '", `widthcheck` = "' . pSQL($row[34]) . '", `step_width` = "' . pSQL($row[35]) . '", `mindepth` = "' . pSQL($row[36]) . '", `maxdepth` = "' . pSQL($row[37]) . '", `maxdepthunit` = "' . pSQL($row[38]) . '", `depthcheck` = "' . pSQL($row[39]) . '", `step_depth` = "' . pSQL($row[40]) . '", `minweight` = "' . pSQL($row[41]) . '", `maxweight` = "' . pSQL($row[42]) . '", `maxweightunit` = "' . pSQL($row[43]) . '", `weightcheck` = "' . pSQL($row[44]) . '" WHERE `id_shop` = ' . pSQL((int) $row[0]) . ' AND `id_product` = ' . pSQL((int) $row[1]) . ''); } } if (Tools::getIsset($sucs) || $sucs !== null) { $import_OK = $smarty->fetch(_PS_ROOT_DIR_ . '\\modules\\squaremeter\\views\\templates\\admin\\import\\import_OK.tpl'); echo $import_OK; } else { $import_Fail = $smarty->fetch(_PS_ROOT_DIR_ . '\\modules\\squaremeter\\views\\templates\\admin\\import\\import_Fail.tpl'); echo $import_Fail; }