Jump to content

[Solved] show numbers best seller like a top 5


randysantino

Recommended Posts

Hi,

Can someone help me modify the 'best seller' block?
I like to make a sort of Top5 block with best sold products.
Since I sell downloads it would be more logical to remove the images
and make a short description of the title.

I would manage to make something like this:

|||||||||||  TOP 5  |||||||||||||||

1) (name-product) - (name-manufacture)
  (feature description)
2) Billie Jean - Michael Jackson
  Genre: classics
3) Black Eyed Peas - I gotta feeling
  Genre: dance
4) etc


It shouldn't be hard I think, but I don't have the know-how to do this.

Link to comment
Share on other sites

Hi;
Open the /prestashop-root/modules/blockbestsellers/blockbestsellers.tpl file

And remove 32th to 35th lines (

  • ....)

>        </pre>
<ul>
getImageLink($best_sellers.0.link_rewrite, $best_sellers.0.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.0.legend|escape:'htmlall':'UTF-8'}" />
           {if $best_sellers|@count > 1}getImageLink($best_sellers.1.link_rewrite, $best_sellers.1.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.1.legend|escape:'htmlall':'UTF-8'}" />{/if}
</ul>



Thats all. (ps v1.4.3)

Or use an already modified file was attached ;)
good luck

blockbestsellers.zip

Link to comment
Share on other sites

Hi
You can give numbers by using

  1. ....
tag in html.
Eg: find and change following

>        </pre>
<dl>{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}</dl>



to

        
       {foreach from=$best_sellers item=product name=myLoop}
{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
       {/foreach}

  • Like 1
Link to comment
Share on other sites

This is what I figured out my self:

blocktopseller.php:

public function hookRightColumn($params)
   {
       if (Configuration::get('PS_CATALOG_MODE'))
           return ;

       global $smarty;
       $currency = new Currency((int)($params['cookie']->id_currency));
       $bestsellers = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5);
       if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
           return;
       $best_sellers = array();
       foreach ($bestsellers AS $bestseller)
       {
           $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
           $best_sellers[] = $bestseller;
       }
       foreach (range(1, 5) AS $number)
       {
           $number;
       }
       $smarty->assign(array(
           'best_sellers' => $best_sellers,
           'number' => $number,
           'mediumSize' => Image::getSize('medium')));
       return $this->display(__FILE__, 'blockbestsellers.tpl');
   }



And the tpl file:

<!-- MODULE Block best sellers -->

getPageLink('best-sales.php')}">{l s='Top sellers' mod='blockbestsellers'}

   {if $best_sellers|@count > 0}
{$number} - {$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}{$manufacturer.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}

getPageLink('best-sales.php')}" title="{l s='All best sellers' mod='blockbestsellers'}" class="button_large">{l s='All best sellers' mod='blockbestsellers'}
   {else}

{l s='No best sellers at this time' mod='blockbestsellers'}
   {/if}


<!-- /MODULE Block best sellers -->




But all I see is this:

5 - (product title)
5 - (product title)
5 - (product title)
5 - (product title)
5 - (product title)

All the titles have the number 5 before it....
But is has to be from 1 to 5 .

Link to comment
Share on other sites

Hi
You can give numbers by using
  1. ....
tag in html.
Eg: find and change following

>        </pre>
<dl>{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}</dl>



to

        
       {foreach from=$best_sellers item=product name=myLoop}
{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
       {/foreach}



Whuahhaa... That's exactly what I mean!
I was thinking to hard I guess... LOL
Link to comment
Share on other sites

Hi;
Your foreach makes $number integer. So you see "5".
You must give a change to smarty. It can do it.

You can simple use

$smarty.foreach. .index

for getting loop ordinate.
So Changing

{$number}


to

{$smarty.foreach.myLoop.index}

in your TPL file, will fix it.

Good luck

Link to comment
Share on other sites

One more thing (Steve Jobs kinda voice).....

How can I echo the manufacturer name? I like to have it BEFORE the product name...

Im sorry thats imposible without edit php
Block best sellers module, gets only following fields

Array
(
   [id_product] => 1
   [link_rewrite] => ipod-nano
   [name] => iPod Nano
   [description_short] =>asdasdasdlasks as.dç ö.asçdö .aç
   [id_image] => 1-37
   [legend] => iPod Nano
   [sales] => 14
   [ean13] => 0
   [upc] => 
   [category] => music-ipods
   [link] => http://......ct=1
)



You may query Product by id_product than get Manufacturer by product->id_manufacturer ....

Link to comment
Share on other sites


You may query Product by id_product than get Manufacturer by product->id_manufacturer ....


Thank you Mahmutta.

Can you help me with the code??


Find following lines 100-101 in blockbestseller.php
foreach ($bestsellers AS $bestseller)
       {


Add this lines after it

           $pro = new Product ($bestseller['id_product'], (int)($params['cookie']->id_lang));
           $man = new Manufacturer($pro->id_manufacturer);
           $bestseller['manufacturer'] = $man->name;



Replace line 34th in blockbestseller.tpl to following

{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'} {$product.manufacturer}


thats all
Modified files attached

bestsellers.zip

Link to comment
Share on other sites

Sorry to border you one more time my friend ;-)

Now I want to show one value of the features. This is what I tried so far:

Php file after

foreach ($bestsellers AS $bestseller)
       {
           $pro = new Product ($bestseller['id_product'], (int)($params['cookie']->id_lang));
           $man = new Manufacturer($pro->id_manufacturer);
           $bestseller['manufacturer'] = $man->name;



I put this

    

           $feat = new Feature ($bestseller['id_feature'], (int)($params['cookie']->id_lang));
           $featval = new FeatureValue($feat->id_feature_value);
           $bestseller['feature'] = $featval->value;



And in tpl file (got it from my 1.3.7 template):

{foreach from=$product.features item=feature}
               {if $feature.name eq "Genre: "}{$feature.value}{/if}
               {/foreach}



Must be doing stupid here... :-s

Can you help me one more time please?

Link to comment
Share on other sites

  • 1 year later...

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...