getProductLink((int)$row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']); $row['attribute_price'] = (isset($row['id_product_attribute']) AND $row['id_product_attribute']) ? (float)(Product::getProductAttributePrice($row['id_product_attribute'])) : 0; $row['price_tax_exc'] = Product::getPriceStatic((int)$row['id_product'], false, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), (self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6)); if (self::$_taxCalculationMethod == PS_TAX_EXC) { $row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2); $row['price'] = Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), 6); $row['price_without_reduction'] = Product::getPriceStatic((int)$row['id_product'], false, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), 2, NULL, false, false); } else { $row['price'] = Tools::ps_round(Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), 2), 2); $row['price_without_reduction'] = Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), 6, NULL, false, false); } $row['reduction'] = Product::getPriceStatic((int)($row['id_product']), (bool)$usetax, (int)($row['id_product_attribute']), 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices); $row['specific_prices'] = $specific_prices; if ($row['id_product_attribute']) { $row['quantity_all_versions'] = $row['quantity']; $row['quantity'] = Product::getQuantity((int)$row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL); } $row['id_image'] = Product::defineProductImage($row, $id_lang); $row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']); $row['attachments'] = ((!isset($row['cache_has_attachments']) OR $row['cache_has_attachments']) ? Product::getAttachmentsStatic((int)($id_lang), $row['id_product']) : array()); // Pack management $row['pack'] = (!isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int)$row['cache_is_pack']); $row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array(); $row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0; if ($row['pack'] AND !Pack::isInStock($row['id_product'])) $row['quantity'] = 0; if ($cached) { self::$producPropertiesCache[$cacheKey] = $row; return self::$producPropertiesCache[$cacheKey]; } else { return $row; } } public function toggleCoupCoeur(){ if($this->online_only == 1){ $this->online_only = 0; $this->save(); }else{ $this->online_only = 1; $this->save(); } } public static function getDetailsCombination($id_product_attribute, $id_lang) { return Db::getInstance()->ExecuteS(' SELECT pa.*, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, al.`name` AS attribute_name, a.`id_attribute`, pa.`unit_price_impact` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($id_lang).') WHERE pa.`id_product_attribute` = '.(int)($id_product_attribute).' ORDER BY pa.`id_product_attribute`'); } public static function duplicateOneAttribute($id_product_old, $id_product_new, $old_attribute_id) { $return = true; $combinationImages = array(); $result = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)($id_product_old).' AND `id_product_attribute` = '.(int)($old_attribute_id)); foreach ($result as $row) { $id_product_attribute_old = (int)($row['id_product_attribute']); $result2 = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'product_attribute_combination` WHERE `id_product_attribute` = '.$id_product_attribute_old); $row['id_product'] = $id_product_new; unset($row['id_product_attribute']); $return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute', $row, 'INSERT'); $id_product_attribute_new = (int)(Db::getInstance()->Insert_ID()); if ($resultImages = self::_getAttributeImageAssociations($id_product_attribute_old)) { $combinationImages['old'][$id_product_attribute_old] = $resultImages; $combinationImages['new'][$id_product_attribute_new] = $resultImages; } foreach ($result2 AS $row2) { $row2['id_product_attribute'] = $id_product_attribute_new; $return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute_combination', $row2, 'INSERT'); } } return !$return ? false : $combinationImages; } }