Jump to content

Module bestsellers


Recommended Posts



Ive tried lot of ways to get correct result, but still I can`t do it..


Prestashop module: bestsellers


In TPL file I have price: {$product.price}


And it shows me: 1 230,00 Eur


If I would like to show something more: pay for it in 24 months Im using: {$product.price / 24} but I got result 1 / 24. It seems he couldn`t get full price. It should do: 1 230 / 4


In blockbestsellers.php:

foreach ($result as &$row)
            $row['price'] = Tools::displayPrice(Product::getPriceStatic((float)($bestseller['id_product'])), $currency)

Its default prestashop method to get price, but maybe I should get in other way to display it correct? Other modules like homefeatured, newproducts block works perfect..

Link to comment
Share on other sites

Hi cikcak,

Easiest is just to modify blockbestsellers.php first:


edit file modules/blockbestsellers/blockbestsellers.php:  (make backup!)


edit function: (sample code from PrestaShop   (add red code)


protected function getBestSellers($params)
  if (Configuration::get('PS_CATALOG_MODE'))
    return false;
  if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 8)))
    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) {  // <- con't forget this bracket
    $row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency);
    $row['price24'] = Tools::displayPrice(((float)Product::getPriceStatic((int)$row['id_product'], $usetax)/24), $currency);
  }   // <- con't forget this bracket
  return $result;
What we do here is make a new variable 'price24' that get the value of price/24
Then, go to themes/<your theme folder>/modules/blockbestsellers/blockbestsellers.tpl  (make backup!)
and add the code to display the value:
Somewhere almost at the end of the file, you see this piece of code. Add the red code again:
            <p class="product-description">{$product.description_short|strip_tags:'UTF-8'|truncate:75:'...'}</p>
            {if !$PS_CATALOG_MODE}
                <div class="price-box">
                    <span class="price">{$product.price}</span>
                    <span class="price"> or 24 months x {$product.price24}</span>
Hope this helps,
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...