2015-08-27 14:48:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class BlockBestSellersOverride extends BlockBestSellers
|
|
|
|
{
|
|
|
|
public function install()
|
|
|
|
{
|
|
|
|
if (!parent::install()
|
|
|
|
|| !$this->registerHook('displayHome')
|
|
|
|
)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hookdisplayHome($params)
|
|
|
|
{
|
|
|
|
if (!$this->isCached('blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home')))
|
|
|
|
{
|
|
|
|
BlockBestSellers::$cache_best_sellers = $this->getBestSellers($params);
|
|
|
|
$this->smarty->assign(array(
|
|
|
|
'best_sellers' => BlockBestSellers::$cache_best_sellers,
|
|
|
|
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BlockBestSellers::$cache_best_sellers === false)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return $this->display(__FILE__, 'blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home'));
|
|
|
|
}
|
|
|
|
|
2015-10-15 12:17:21 +02:00
|
|
|
|
|
|
|
protected function getBestSellers($params)
|
|
|
|
{
|
|
|
|
if (Configuration::get('PS_CATALOG_MODE'))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!($result = ProductSale::getProductHome((int)$params['cookie']->id_lang, 0, (int)Configuration::get('PS_BLOCK_BESTSELLERS_TO_DISPLAY'))))
|
|
|
|
return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false);
|
|
|
|
|
|
|
|
$currency = new Currency($params['cookie']->id_currency);
|
|
|
|
$usetax = (Product::getTaxCalculationMethod((int)$this->context->customer->id) != PS_TAX_EXC);
|
|
|
|
foreach ($result as &$row)
|
|
|
|
$row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2015-08-27 14:48:06 +02:00
|
|
|
}
|