* @copyright 2007-2014 RSI * @license http://catalogo-onlinersi.net */ class MassPrice extends Module { private $_html = ""; private $_postErrors = []; public function __construct() { $this->name = "massprice"; $this->module_key = "c22aa30c1a5d33d5e8c7d59a1f412e38"; if (_PS_VERSION_ < "1.4.0.0") { $this->tab = "Tools"; } if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { $this->tab = "administration"; $this->author = "RSI"; $this->need_instance = 1; } if (_PS_VERSION_ > "1.5.0.0") { $this->tab = "administration"; $this->author = "RSI"; } if (_PS_VERSION_ > "1.6.0.0") { $this->bootstrap = true; } $this->version = "4.0.0"; parent::__construct(); $this->displayName = $this->l("Mass price update"); $this->description = $this->l( "Mass price update by category-www.catalogo-onlinersi.net" ); if (_PS_VERSION_ < "1.5") { require _PS_MODULE_DIR_ . $this->name . "/backward_compatibility/backward.php"; } } public function install() { if ( !Configuration::updateValue("MASSPRICE_NBR", 1) || !parent::install() || !$this->registerHook("header") ) { return false; } if (!Configuration::updateValue("MASSPRICE_SKIP_CAT", 1)) { return false; } if (!Configuration::updateValue("MASSPRICE_REQUIERED1", 0)) { return false; } if (!Configuration::updateValue("MASSPRICE_MIN", "")) { return false; } if (!Configuration::updateValue("MASSPRICE_MAX", "")) { return false; } if (!Configuration::updateValue("MASSPRICE_SYMBOL", 0)) { return false; } if (!Configuration::updateValue("MASSPRICE_COMB", 0)) { return false; } if (!Configuration::updateValue("MASSPRICE_LAST", "")) { return false; } return true; } private function _displayInfo() { $this->context->smarty->assign( "last", Configuration::get("MASSPRICE_LAST") ); return $this->display(__FILE__, "views/templates/hook/infos.tpl"); } private function _displayAdds() { return $this->display(__FILE__, "views/templates/hook/adds.tpl"); } public function getConfigFieldsValues() { /*categories*/ /* $typec = Category::getCategories($this->context->language->id, true, false); $id_category = array(); foreach ($typec as $type) if (!is_null(Tools::getValue('skipcat_'.(int)$type['id_category']))) $id_category['skipcat_'.(int)$type['id_category']] = true; $types2 = Category::getCategories($this->context->language->id, true, false); $id_category = array(); foreach ($types2 as $type2) $id_category[] = $type2['id_category']; $id_category_post = array(); foreach ($id_category as $id) if (Tools::getValue('skipcat_'.(int)$id)) $id_category_post['skipcat_'.(int)$id] = true; $id_category_config = array(); if ($confs2 = Configuration::get('MASSPRICE_SKIP_CAT')) $confs2 = explode(',', Configuration::get('MASSPRICE_SKIP_CAT')); else $confs2 = array(); foreach ($confs2 as $conf2) $id_category_config['skipcat_'.(int)$conf2] = true;/* /*attributes*/ /*categories*/ /**/ $fields_values = [ "nbr" => Tools::getValue( "nbr", Configuration::get("MASSPRICE_NBR") ), "requiered1" => Tools::getValue( "requiered1", Configuration::get("MASSPRICE_REQUIERED1") ), "symbol" => Tools::getValue( "symbol", Configuration::get("MASSPRICE_SYMBOL") ), "comb" => Tools::getValue( "comb", Configuration::get("MASSPRICE_COMB") ), "min" => Tools::getValue( "min", Configuration::get("MASSPRICE_MIN") ), "max" => Tools::getValue( "max", Configuration::get("MASSPRICE_MAX") ), "last" => Tools::getValue( "last", Configuration::get("MASSPRICE_LAST") ), "skipcat" => Tools::getValue( "skipcat", explode(",", Configuration::get("MASSPRICE_SKIP_CAT")) ), ]; /*$fields_values = array_merge($fields_values, array_intersect($id_category_config, $id_category_config));*/ return $fields_values; } public function postProcess() { $errors = ""; $_html = ""; $skipcat = ""; $skipman = ""; $skipatt = ""; if (Tools::isSubmit("submitMassPrice")) { /*$types2 = Category::getCategories($this->context->language->id, true, false); $id_category = array(); foreach ($types2 as $type2) if (Tools::getValue('skipcat_'.(int)$type2['id_category'])) $id_category[] = $type2['id_category']; /*attributes*/ /* Configuration::updateValue('MASSPRICE_SKIP_CAT', implode(',', $id_category));*/ if ($skipcat = Tools::getValue("skipcat")) { Configuration::updateValue( "MASSPRICE_SKIP_CAT", implode(",", $skipcat) ); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_SKIP_CAT"); } if ($nbr = Tools::getValue("nbr")) { Configuration::updateValue("MASSPRICE_NBR", $nbr); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_NBR"); } if ($requiered1 = Tools::getValue("requiered1")) { Configuration::updateValue("MASSPRICE_REQUIERED1", $requiered1); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_REQUIERED1"); } if ($symbol = Tools::getValue("symbol")) { Configuration::updateValue("MASSPRICE_SYMBOL", $symbol); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_SYMBOL"); } if ($min = Tools::getValue("min")) { Configuration::updateValue("MASSPRICE_MIN", $min); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_MIN"); } if ($max = Tools::getValue("max")) { Configuration::updateValue("MASSPRICE_MAX", $max); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_MAX"); } if ($comb = Tools::getValue("comb")) { Configuration::updateValue("MASSPRICE_COMB", $comb); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_COMB"); } if ($last = Tools::getValue("last")) { Configuration::updateValue("MASSPRICE_LAST", $last); } elseif ( Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP ) { Configuration::deleteFromContext("MASSPRICE_LAST"); } if ($symbol == 0) { $sy = "-"; } if ($symbol == 1) { $sy = "+"; } if ($symbol == 2) { $sy = $this->l("New value"); } if ($requiered1 == 0) { $re = $this->l("Amount"); } if ($requiered1 == 1) { $re = "%"; } if ($comb == 0) { $co = $this->l( "Dont update combinations, only update base price" ); } if ($comb == 1) { $co = $this->l("Update base price and combination price"); } if ($comb == 2) { $co = $this->l("Update combinations, dont update base price"); } $last = $this->l( "Price increment:" . (float) $nbr . ",Type of increment:" . $sy . " in " . $re . " - " . $co . " on categories ID:" . (string) Configuration::get("MASSPRICE_SKIP_CAT") ); Configuration::updateValue("MASSPRICE_LAST", $last); $this->updateall(); } return $this->_html; } public function renderForm() { /*manufacturers*/ /*categories*/ $root = Category::getRootCategory(); $selected_cat = explode(",", Configuration::get("MASSPRICE_SKIP_CAT")); $tree = new HelperTreeCategories("categories-treeview"); $tree ->setUseCheckBox(true) ->setAttribute("is_category_filter", $root->id) ->setRootCategory($root->id) ->setSelectedCategories($selected_cat) ->setUseSearch(true) ->setInputName("skipcat"); $categoryTreeCol1 = $tree->render(); $types2 = Category::getCategories( $this->context->language->id, true, false ); foreach ($types2 as $key => $type) { $types2[$key]["label"] = $type["name"]; } /*attributes*/ $options2 = [ [ "id_option" => "1", // The value of the 'value' attribute of the tag. "name" => "+", // The value of the text content of the tag. ], [ "id_option" => "0", "name" => "-", ], [ "id_option" => "2", "name" => $this->l( "New value (dont use percentage or amount )" ), ], ]; $options3 = [ [ "id_option" => "1", // The value of the 'value' attribute of the tag. "name" => $this->l("Percentage"), // The value of the text content of the tag. ], [ "id_option" => "0", "name" => $this->l("Amount"), ], ]; $options4 = [ [ "id_option" => "0", "name" => $this->l( "Dont update combinations, only update base price" ), ], ]; $fields_form = [ "form" => [ "legend" => [ "title" => $this->l("Configuration"), "icon" => "icon-cogs", ], "input" => [ [ "type" => "text", "label" => $this->l("Price value"), "name" => "nbr", "desc" => $this->l( "Percentage or amount to increase/decrease/new price" ), ], [ "type" => "select", "label" => $this->l("Increase or decrease"), "name" => "symbol", "options" => [ "query" => $options2, "id" => "id_option", "name" => "name", ], ], [ "type" => "select", "label" => $this->l("Type of update"), "name" => "requiered1", "options" => [ "query" => $options3, "id" => "id_option", "name" => "name", ], ], [ "type" => "text", "label" => $this->l("Min price range"), "name" => "min", "desc" => $this->l( "The minimun price range to update. The module updates base prices that are greater than this minimum (leave blank to skip)" ), ], [ "type" => "text", "label" => $this->l("Max price range"), "name" => "max", "desc" => $this->l( "The maximun price range to update. The module updates base prices that are less than this maximum (leave blank to skip)" ), ], [ "type" => "select", "label" => $this->l("Update product combinations?"), "name" => "comb", "class" => "l", "options" => [ "query" => $options4, "id" => "id_option", "name" => "name", ], ], [ "type" => "categories_select", "label" => $this->l("Shop category to include"), "desc" => $this->l( "Select the categories you want to change price for each product in selectec categories" ), "name" => "skipcat", "category_tree" => $categoryTreeCol1, //This is the category_tree called in form.tpl ], ], "submit" => [ "title" => $this->l("Update prices"), ], ], ]; $helper = new HelperForm(); $helper->show_toolbar = true; $helper->table = $this->table; $lang = new Language((int) Configuration::get("PS_LANG_DEFAULT")); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get( "PS_BO_ALLOW_EMPLOYEE_FORM_LANG" ) ? Configuration::get("PS_BO_ALLOW_EMPLOYEE_FORM_LANG") : 0; $this->fields_form = []; $helper->identifier = $this->identifier; $helper->submit_action = "submitMassPrice"; $helper->currentIndex = $this->context->link->getAdminLink("AdminModules", false) . "&configure=" . $this->name . "&tab_module=" . $this->tab . "&module_name=" . $this->name; $helper->token = Tools::getAdminTokenLite("AdminModules"); $helper->tpl_vars = [ "fields_value" => $this->getConfigFieldsValues(), "languages" => $this->context->controller->getLanguages(), "id_language" => $this->context->language->id, ]; return $helper->generateForm([$fields_form]); } public function displayForm() { $this->_html .= ' ' . $this->l("Settings") . ' ' . $this->l("Last rule used: ") . "" . Configuration::get("MASSPRICE_LAST") . ' ' . $this->l("Price value") . ' ' . $this->l("Percentage or amount to increase/decrease/new price") . ' ' . $this->l("Increase or decrease") . ' " . $this->l("+") . ' " . $this->l("-") . ' " . $this->l("New value (dont use percentage or amount )") . ' ' . $this->l("Type of update") . ' " . $this->l("Percentage") . ' " . $this->l("Amount") . ' ' . $this->l("Update product combinations?") . ' " . $this->l("Dont update combinations, only update base price") . ' ' . $this->l("Min price range") . ' ' . $this->l( "The minimun price range to update. The module updates base prices that are greater than this minimum (leave blank to skip)" ) . ' ' . $this->l("Max price range") . ' ' . $this->l( "The maximun price range to update. The module updates base prices that are less than this maximum (leave blank to skip)" ) . ' '; $skipcat = Configuration::get("MASSPRICE_SKIP_CAT"); if (!empty($skipcat)) { $skipcat_array = explode(",", $skipcat); } else { $skipcat_array = []; } $this->_html .= ' ' . $this->l("Shop category to include") . ' '; $categories = Category::getCategories($this->context->language->id); ob_start(); $this->recurseCategory( $categories, $categories[0][1], 1, $skipcat_array ); $this->_html .= ob_get_contents(); ob_end_clean(); $this->_html .= ' ' . $this->l( "Select the categories you want to change price for each product in selectec categories" ) . ' README TERMS Follow us: Video: Other products: ' . $this->l("Contribute") . ' ' . $this->l( "You can contribute with a donation if our free modules and themes are usefull for you. Clic on the link and support us!" ) . ' ' . $this->l( "For more modules & themes visit: www.catalogo-onlinersi.com.ar" ) . ' '; return $this->_html; } public function updateall() { $errors = ""; $nbr = Configuration::get("MASSPRICE_NBR"); $min = Configuration::get("MASSPRICE_MIN"); $max = Configuration::get("MASSPRICE_MAX"); $requiered1 = Configuration::get("MASSPRICE_REQUIERED1"); $symbol = Configuration::get("MASSPRICE_SYMBOL"); $comb = Configuration::get("MASSPRICE_COMB"); $skipcat = Configuration::get("MASSPRICE_SKIP_CAT"); $skipcategory = Configuration::get("MASSPRICE_SKIP_CAT"); ($GLOBALS["___mysqli_ston"] = mysqli_connect( _DB_SERVER_, _DB_USER_, _DB_PASSWD_ )) || die( is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false) ); mysqli_query($GLOBALS["___mysqli_ston"], "SET NAMES UTF8"); //this is needed for UTF 8 characters - multilanguage ((bool) mysqli_query( $GLOBALS["___mysqli_ston"], "USE " . constant("_DB_NAME_") )) || die( is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false) ); $sorgudc = mysqli_query( $GLOBALS["___mysqli_ston"], ' SELECT p.*, pl.*, cp.* FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON p.`id_product` = cp.`id_product` LEFT JOIN `' . _DB_PREFIX_ . "product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = " . $this->context->language->id . ') WHERE cp.`id_category` IN (' . (string) $skipcategory . ') ' . ((string) $min != null ? " AND p.`price` >= (" . (string) $min . ")" : "") . ' ' . ((string) $max != null ? " AND p.`price` <= (" . (string) $max . ")" : "") . ' GROUP BY p.`id_product`' ); if (!$sorgudc) { return false; } $veridc = mysqli_fetch_assoc($sorgudc); $rowcount = mysqli_num_rows($sorgudc); $sorgudc5 = mysqli_query( $GLOBALS["___mysqli_ston"], ' SELECT p.*, pl.*, cp.* FROM `' . _DB_PREFIX_ . "product" . (_PS_VERSION_ > "1.5.0.0" ? "_shop" : "") . '` p LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON p.`id_product` = cp.`id_product` LEFT JOIN `' . _DB_PREFIX_ . "product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = " . $this->context->language->id . ') ' . (_PS_VERSION_ > "1.5.0.0" ? "LEFT JOIN `" . _DB_PREFIX_ . "product` ps ON p.`id_product` = ps.`id_product`" : "") . ' WHERE cp.`id_category` IN (' . (string) $skipcategory . ") " . (_PS_VERSION_ > "1.5.0.0" ? "AND p.`id_shop` = " . (int) $this->context->shop->id : "") . ' ' . ((string) $min != null ? " AND p.`price` >= (" . (string) $min . ")" : "") . ' ' . ((string) $max != null ? " AND p.`price` <= (" . (string) $max . ")" : "") . ' GROUP BY p.`id_product`' ); $veridc5 = mysqli_fetch_assoc($sorgudc5); $rowcount2 = mysqli_num_rows($sorgudc); $sorgu4 = "SELECT * FROM `" . _DB_PREFIX_ . "product_attribute_combination` GROUP BY id_product_attribute"; $resultado4 = mysqli_query($GLOBALS["___mysqli_ston"], $sorgu4); $veri4 = mysqli_fetch_array($resultado4); $varrr = ' SELECT p.*, pl.*, cp.* FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON p.`id_product` = cp.`id_product` LEFT JOIN `' . _DB_PREFIX_ . "product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = " . $this->context->language->id . ') WHERE cp.`id_category` IN (' . (string) $skipcategory . ') ' . ((string) $min != null ? " AND p.`price` >= (" . (string) $min . ")" : "") . ' ' . ((string) $max != null ? " AND p.`price` <= (" . (string) $max . ")" : "") . ' GROUP BY p.`id_product`'; $i = 0; do { $i++; $sorgudc2 = mysqli_query( $GLOBALS["___mysqli_ston"], ' SELECT * FROM `' . _DB_PREFIX_ . "product" . (_PS_VERSION_ > "1.5.0.0" ? "_shop" : "") . '` WHERE `id_product` = ' . (int) $veridc["id_product"] . " " . (_PS_VERSION_ > "1.5.0.0" ? "AND `id_shop` = " . (int) $this->context->shop->id : "") . ' ' ); $veridc2 = mysqli_fetch_assoc($sorgudc2); //var_dump($a); /**/ // Db::getInstance()->Execute("RESET QUERY CACHE;"); if ($rowcount > 0 || $rowcount2 > 0) { if ($symbol == 1 && $requiered1 == 0) { $price = $veridc["price"] + $nbr; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ). " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pricea = $veri3["price"] + $nbr; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } if ($symbol == 0 && $requiered1 == 0) { $price = $veridc["price"] - $nbr; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ). " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { // echo $sorgu3.''.(int)$veri3['id_product_attribute'].'-'.$veri3['id_product'].''; $pricea = $veri3["price"] - $nbr; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pricea = $veri3f["price"] - $nbr; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } if ($symbol == 1 && $requiered1 == 1) { $per = ($veridc["price"] * $nbr) / 100; $price = $veridc["price"] + $per; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { //echo $sorgu3.''.(int)$veri3['id_product_attribute'].'-'.$veri3['id_product'].''; $pera = ($veri3["price"] * $nbr) / 100; $pricea = $veri3["price"] + $pera; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string)($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ). " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pera = ($veri3f["price"] * $nbr) / 100; $pricea = $veri3f["price"] + $pera; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } if ($symbol == 0 && $requiered1 == 1) { $per = ($veridc["price"] * $nbr) / 100; $price = $veridc["price"] - $per; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pera = ($veri3["price"] * $nbr) / 100; $pricea = $veri3["price"] - $pera; //echo $sorgu3.''.(int)$veri3['id_product_attribute'].'-'.$veri3['id_product'].''; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string)($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pera = ($veri3f["price"] * $nbr) / 100; $pricea = $veri3f["price"] - $pera; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } if ($symbol == 2 && $requiered1 == 1) { $per = $nbr; $price = $per; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pera = $nbr; $pricea = $per; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string)($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ). " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { $pera = $nbr; $pricea = $per; if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } if ($symbol == 2 && $requiered1 == 0) { $price = $nbr; if (_PS_VERSION_ > "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . ";" ); Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product_shop` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . (int) $veridc["id_product"] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . (int) $this->context->shop->id . ";" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product context->language->id . '" target="_blank">' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { //echo $sorgu3.''.(int)$veri3['id_product_attribute'].'-'.$veri3['id_product'].''; $pricea = $nbr; if ( (int) $veri3["id_product_attribute"] != null ) { if ( (int) $veri3["id_product_attribute"] != null ) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } } while ($veri3 = mysqli_fetch_assoc($resultado3)); } } if (_PS_VERSION_ < "1.5.0.0") { if ($comb != "2") { Db::getInstance()->Execute( "UPDATE `" . _DB_PREFIX_ . "product` SET `price` = " . (float) $price . " WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . (int) $veridc["id_product"] . " ;" ); $this->_html .= $this->displayConfirmation( 'UPDATE Product ' . (string) ($veridc["name"] ? $veridc["name"] : $veridc["id_product"] ) . " to price " . (float) $price . "" ); } if ($comb == "1" || $comb == "2") { do { //echo $sorgu3f.''.$veri3f['id_product_attribute'].'-'.$veri3f['id_product'].''; $pricea = $nbr; if ($veri3f["id_product_attribute"] != null) { } else { $this->_html .= $this->displayConfirmation( "No combination match (product dont have this combination or any combination)" ); } } while ( $veri3f = mysqli_fetch_assoc($resultado3f) ); } } } } //$this->_html .= $errors == '' ? $this->displayConfirmation('Products updated successfully') : @$errors; else { $this->_html .= $this->displayConfirmation("No products match"); } } while ($veridc = mysqli_fetch_assoc($sorgudc)); } public function getContent() { $errors = ""; if (_PS_VERSION_ < "1.6.0.0") { if (Tools::isSubmit("submitMassPrice")) { $nbr = Tools::getValue("nbr"); $requiered1 = Tools::getValue("requiered1"); $symbol = Tools::getValue("symbol"); $comb = Tools::getValue("comb"); $min = Tools::getValue("min"); $max = Tools::getValue("max"); if ($symbol == 0) { $sy = "-"; } if ($symbol == 1) { $sy = "+"; } if ($symbol == 2) { $sy = $this->l("New value"); } if ($requiered1 == 0) { $re = $this->l("Amount"); } if ($requiered1 == 1) { $re = "%"; } if ($comb == 0) { $co = $this->l( "Dont update combinations, only update base price" ); } if ($comb == 1) { $co = $this->l("Update base price and combination price"); } if ($comb == 2) { $co = $this->l( "Update combinations, dont update base price" ); } $skipcat = Tools::getValue("skipcat"); Configuration::updateValue("MASSPRICE_NBR", $nbr); Configuration::updateValue("MASSPRICE_SYMBOL", $symbol); Configuration::updateValue("MASSPRICE_COMB", $comb); Configuration::updateValue("MASSPRICE_REQUIERED1", $requiered1); Configuration::updateValue("MASSPRICE_MIN", $min); Configuration::updateValue("MASSPRICE_MAX", $max); if (!empty($skipcat)) { Configuration::updateValue( "MASSPRICE_SKIP_CAT", implode(",", $skipcat) ); } $skipcategory = Configuration::get("MASSPRICE_SKIP_CAT"); $last = $this->l( "Price increment:" . (float) $nbr . ",Type of increment:" . $sy . " in " . $re . " - " . $co . " on categories ID:" . (string) $skipcategory ); Configuration::updateValue("MASSPRICE_LAST", $last); $this->updateall(); } return $this->displayForm(); } else { if (((bool) Tools::isSubmit("submitMassPrice")) == true) { $postp = $this->postProcess(); } if (@Tools::getIsset($_GET["section"])) { $index_section = Tools::getValue("section"); } else { $index_section = 1; } $this->context->smarty->assign([ "section_adminpage" => $index_section, "id_shop" => $this->context->shop->id, "renderForm" => $this->renderForm(), "displayinfo" => $this->_displayInfo(), "displayadds" => $this->_displayAdds(), "psversion" => _PS_VERSION_, "baseurl" => _PS_BASE_URL_ . _MODULE_DIR_, "idshop" => $this->context->shop->id, "server" => $_SERVER["REQUEST_URI"], "module_dir" => $this->_path, ]); $output = $this->context->smarty->fetch( $this->local_path . "views/templates/hook/configure.tpl" ); return (isset($postp) ? $postp : "") . $output; } } public function getProductscath($idcat) { ($GLOBALS["___mysqli_ston"] = mysqli_connect( _DB_SERVER_, _DB_USER_, _DB_PASSWD_ )) || die( is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false) ); mysqli_query($GLOBALS["___mysqli_ston"], "SET NAMES UTF8"); //this is needed for UTF 8 characters - multilanguage ((bool) mysqli_query( $GLOBALS["___mysqli_ston"], "USE " . constant("_DB_NAME_") )) || die( is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false) ); $sql = 'SELECT p.* FROM `' . _DB_PREFIX_ . 'product` p WHERE p.`id_category_default` ' . (_PS_VERSION_ > "1.5.0.0" ? "AND id_shop_default = " . $this->context->shop->id : "") . " IN (" . $idcat . ") GROUP BY p.`id_product`"; $result = Db::getInstance()->Execute($sql); } public function recurseCategory( $categories, $current, $id_category = 1, $selectids_array ) { if ( str_repeat(" ", $current["infos"]["level_depth"] * 5) . preg_replace( "/^[0-9]+\./", "", Tools::stripslashes($current["infos"]["name"]) ) != "Root" ) { if ($id_category != null && $current["infos"]["name"] != null) { echo '" . str_repeat(" ", $current["infos"]["level_depth"] * 5) . preg_replace( "/^[0-9]+\./", "", Tools::stripslashes($current["infos"]["name"]) ) . ""; } } if (isset($categories[$id_category])) { foreach ($categories[$id_category] as $key => $row) { $this->recurseCategory( $categories, $categories[$id_category][$key], $key, $selectids_array ); }; } } }
' . $this->l("Last rule used: ") . "" . Configuration::get("MASSPRICE_LAST") . '
' . $this->l("Percentage or amount to increase/decrease/new price") . '
' . $this->l( "The minimun price range to update. The module updates base prices that are greater than this minimum (leave blank to skip)" ) . '
' . $this->l( "The maximun price range to update. The module updates base prices that are less than this maximum (leave blank to skip)" ) . '
' . $this->l( "Select the categories you want to change price for each product in selectec categories" ) . '
TERMS
Follow us:
Video:
Other products:
' . $this->l( "You can contribute with a donation if our free modules and themes are usefull for you. Clic on the link and support us!" ) . '
' . $this->l( "For more modules & themes visit: www.catalogo-onlinersi.com.ar" ) . '