product->id_category_default; $sale = Sale::getSaleFromCategory($id_category); /* Finding out the right Category for thumb - 4 levels of category */ $product_category = $id_category; $available_cat = $this->product->getCategories(); $first_step_cats = Category::getChildren($sale->id_category,$cookie->id_lang); foreach ($first_step_cats as $key => $first_step_cat) { if(in_array($first_step_cat['id_category'], $available_cat)){ $product_category = $first_step_cat = $first_step_cat['id_category']; break; } } $second_step_cats = (isset($first_step_cat))?Category::getChildren((int)$first_step_cat,$cookie->id_lang):array(); foreach ($second_step_cats as $key => $second_step_cat) { if(in_array($second_step_cat['id_category'], $available_cat)){ $product_category = $second_step_cat = $second_step_cat['id_category']; break; } } $third_step_cats = (isset($second_step_cat))?Category::getChildren((int)$second_step_cat,$cookie->id_lang):array(); foreach ($third_step_cats as $key => $third_step_cat) { if(in_array($third_step_cat['id_category'], $available_cat)){ $product_category = $third_step_cat = $third_step_cat['id_category']; break; } } if (isset($third_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$third_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) { $id_category_thumb = (int)$third_step_cat; } elseif (isset($second_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$second_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) { $id_category_thumb = (int)$second_step_cat; } elseif (isset($first_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$first_step_cat.'_thumb_vp_'.$cookie->id_lang.'.jpg')) { $id_category_thumb = (int)$first_step_cat; // Keeping retrocompatibility } elseif (isset($third_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$third_step_cat.'_thumb_vp.jpg')) { $id_category_thumb = (int)$third_step_cat; } elseif (isset($second_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$second_step_cat.'_thumb_vp.jpg')) { $id_category_thumb = (int)$second_step_cat; } elseif (isset($first_step_cat) && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$first_step_cat.'_thumb_vp.jpg')) { $id_category_thumb = (int)$first_step_cat; // End retrocompatibility } else { // sale cat thumb $id_category_thumb = $sale->id_category; } self::$smarty->assign(array( 'sale' => $sale, 'HOOK_SIMILAR_PRODUCT' => Module::hookExec('similarProduct', array('product' => $this->product, 'sale' => $sale, 'category' => $product_category)), 'HOOK_SIMILAR_PRODUCT_TABLABEL' => Module::hookExec('simlarProductTabLabel', array('product' => $this->product, 'sale' => $sale, 'category' => $product_category)), 'HOOK_PRIVATESALES_PRODUCT' => Module::hookExec('privatesales_product', array('sale' => $sale)), 'is_sale_home' => ($sale? $sale->id_category == $id_category: FALSE), 'is_thumb_vp' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg')), 'is_thumb_vp_lang' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp_'.$cookie->id_lang.'.jpg')), 'id_category_thumb' => $id_category_thumb, )); // assign date estimation from sale delay if (Module::isInstalled('privatesales_delay')) { if (!class_exists('SaleDelay')) { require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php'; } $date = new DateTime(); $delivery_date = SaleDelay::getDeliveryDate(array($sale->delivery_delay), null, $date, true); } } $is_random = Db::getInstance()->getValue(' SELECT `random` FROM `'._DB_PREFIX_.'product_customs` WHERE id_product = '.(int)$this->product->id ); $bestSaleCart = Module::hookExec('bestSaleCart'); // @Override Antadis if (strpos($this->product->description, 'www.bebeboutik.') !== false) { $this->product->description = str_replace('http://www.bebeboutik.','//www.bebeboutik.',$this->product->description); } if (strpos($this->product->description_short, 'www.bebeboutik.') !== false) { $this->product->description_short = str_replace('http://www.bebeboutik.','//www.bebeboutik.',$this->product->description_short); } if (strpos($this->product->description_delivery, 'www.bebeboutik.') !== false) { $this->product->description_delivery = str_replace('http://www.bebeboutik.','//www.bebeboutik.',$this->product->description_delivery); } if (strpos($this->product->description_more, 'www.bebeboutik.') !== false) { $this->product->description_more = str_replace('http://www.bebeboutik.','//www.bebeboutik.',$this->product->description_more); } if (strpos($this->product->description_comment, 'www.bebeboutik.') !== false) { $this->product->description_comment = str_replace('http://www.bebeboutik.','//www.bebeboutik.',$this->product->description_comment); } $back_category = false; $link_back = false; if (isset($_SERVER['HTTP_REFERER'])) { $referer = explode('?', $_SERVER['HTTP_REFERER']); if(is_array($referer) && count($referer)>1) { $link_back = $referer[0]; } else { $url = explode('/', $_SERVER['HTTP_REFERER']); if (count($url) > 3 && count($url) < 5) { $url = explode('-', end($url)); $back_category = (int)$url[0]; } } } if($back_category==0){ $link = new Link(); $link_back = $link->getCategoryLink($sale->id_category, $sale->alias[$cookie->id_lang]); } self::$smarty->assign(array( 'bestSaleCart' => $bestSaleCart, 'back_category' => $back_category, 'link_back' => $link_back, 'product' => $this->product, 'is_random' => $is_random, 'coverImage' => Product::getCover($this->product->id), 'delivery_date' => (!empty($delivery_date)?$delivery_date:null), )); } public function setMedia() { parent::setMedia(); global $css_files; $css_files = array_slice($css_files, 0, 1); if(!_PS_MOBILE_) { Tools::addJS(array( _THEME_JS_DIR_.'jquery.mousewheel.js', _THEME_JS_DIR_.'jquery.jscrollpane.min.js' )); } } }