Jump to content

Number of bestsellers on home page


Yngvi

Recommended Posts

On the home page, there are three tabs....'New Arrivals', 'Popular' and 'Best sellers'

 

I am able to limit the number of products in the other two blocks but not in the 'best sellers' block. Is there are way to limit the number of bestsellers displayed to for example four products.

Link to comment
Share on other sites

unfortunately, there is no option in back office to define how many products you want to display in home best sellers module.

but you can do it manually in module php file.

so open it: /modules/blockbestsellers/blockbestsellers.php

 

there is a code:
 

if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 8)))

8 at the end of this code is a number of products you want to retrieve from database, increase/decrease it to achieve what you exactly expect.

  • Like 2
Link to comment
Share on other sites

i totally forgot to mention that changes like that need recompilation of entire theme (module uses caching system)

so go to adv. parameters > performance tab and click on button to clear shop cache & autoload.

 

in some cases it is also necessary to turn on "force compile option" temporarily.

  • Like 2
Link to comment
Share on other sites

Maybe someone can help me with this. but it seems like i have to clear the cache almost every day since upgrading. If i do not, the home page tabs will show all tabs at the same time. cant figure out any other way to fix it

 

i totally forgot to mention that changes like that need recompilation of entire theme (module uses caching system)

so go to adv. parameters > performance tab and click on button to clear shop cache & autoload.

 

in some cases it is also necessary to turn on "force compile option" temporarily.

Link to comment
Share on other sites

Maybe someone can help me with this. but it seems like i have to clear the cache almost every day since upgrading. If i do not, the home page tabs will show all tabs at the same time. cant figure out any other way to fix it

 

I have the same problem, seems like a bug.

Link to comment
Share on other sites

  • 3 months later...

Actually with 1.6 upgrading modules so frequently you really don't want to update the bestsellers.php file as it's going to get overwritten by an upgrade. You should do it in the theme tpl file at {yourtheme}/modules/bestsellers/bestsellers.tpl. Notice the reduction variable I used here. Change the max_best to the maximum bestsellers you want displayed:

<!-- MODULE Block best sellers -->
<div id="best-sellers_block_right" class="block products_block">
	<h4 class="title_block">
    	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='View a top sellers products' mod='blockbestsellers'}">{l s='Top sellers' mod='blockbestsellers'}</a>
    </h4>
	<div class="block_content">

{assign var="i" value=0}
{assign var="max_best" value=4}

	{if $best_sellers && $best_sellers|@count > 0}
		<ul class="block_content products-block">
			{foreach from=$best_sellers item=product name=myLoop}
            {if $i < $max_best}
			<li class="clearfix">
				<a href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}" class="products-block-image content_img clearfix">
					<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small_default')|escape:'html'}" alt="{$product.legend|escape:'html':'UTF-8'}" />
				</a>
				<div class="product-content">
                	<h5>
                    	<a class="product-name" href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}">
                            {$product.name|strip_tags:'UTF-8'|escape:'html':'UTF-8'}
                        </a>
                    </h5>
                    <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>
                        </div>
                    {/if}
                </div>
			</li>
            {assign var="i" value=$i+1}
            {/if}
		{/foreach}
		</ul>
		<div class="lnk">
        	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='All best sellers' mod='blockbestsellers'}"  class="btn btn-default button button-small"><span>{l s='All best sellers' mod='blockbestsellers'}<i class="icon-chevron-right right"></i></span></a>
        </div>
	{else}
		<p>{l s='No best sellers at this time' mod='blockbestsellers'}</p>
	{/if}
	</div>
</div>
<!-- /MODULE Block best sellers -->

Hope that helps somebody.

 

Wil

Edited by A-Z Hosting (see edit history)
  • Like 4
Link to comment
Share on other sites

  • 2 months later...

Actually with 1.6 upgrading modules so frequently you really don't want to update the bestsellers.php file as it's going to get overwritten by an upgrade. You should do it in the theme tpl file at {yourtheme}/modules/bestsellers/bestsellers.tpl. Notice the reduction variable I used here. Change the max_best to the maximum bestsellers you want displayed:

<!-- MODULE Block best sellers -->
<div id="best-sellers_block_right" class="block products_block">
	<h4 class="title_block">
    	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='View a top sellers products' mod='blockbestsellers'}">{l s='Top sellers' mod='blockbestsellers'}</a>
    </h4>
	<div class="block_content">

{assign var="i" value=0}
{assign var="max_best" value=4}

	{if $best_sellers && $best_sellers|@count > 0}
		<ul class="block_content products-block">
			{foreach from=$best_sellers item=product name=myLoop}
            {if $i < $max_best}
			<li class="clearfix">
				<a href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}" class="products-block-image content_img clearfix">
					<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small_default')|escape:'html'}" alt="{$product.legend|escape:'html':'UTF-8'}" />
				</a>
				<div class="product-content">
                	<h5>
                    	<a class="product-name" href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}">
                            {$product.name|strip_tags:'UTF-8'|escape:'html':'UTF-8'}
                        </a>
                    </h5>
                    <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>
                        </div>
                    {/if}
                </div>
			</li>
            {assign var="i" value=$i+1}
            {/if}
		{/foreach}
		</ul>
		<div class="lnk">
        	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='All best sellers' mod='blockbestsellers'}"  class="btn btn-default button button-small"><span>{l s='All best sellers' mod='blockbestsellers'}<i class="icon-chevron-right right"></i></span></a>
        </div>
	{else}
		<p>{l s='No best sellers at this time' mod='blockbestsellers'}</p>
	{/if}
	</div>
</div>
<!-- /MODULE Block best sellers -->

Hope that helps somebody.

 

Wil

Hi guys, I would like to disable the best sellers tab on the front page. I have uninstalled the module but best sellers still shows. Any ideas how to 'disable ' the best sellers tab?

I have cleared the cache 'force compilation' under the adv. parameters tab. refreshed my site but best sellers tab is still there. I don't know how to disable the tab.

Thanks for the help :-D

Len

Edited by Rosie Posy (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Personalize display module Leo top best sellers :

 

 

Fichier ftp : /www/beta/modules/leoblockbestsellers/leoblockbestsellers.php

 

Ligne = 179 :

$bestsellers = $this->getProducts((int)$this->context->language->id, 1, (int)Configuration::get('PS_BLOCK_LEO_BESTSELLERS_LIMIT'));

 

Replace with :

 

$accessories_cat_id = id_catégories that u want to display;

$category = new Category($accessories_cat_id);

$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));

$bestsellers =  $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

Edited by mbarki chadi (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

I have the same problem but no max_best....

<!-- MODULE Block best sellers -->
<div id="best-sellers_block_right" class="block products_block">
	<h4 class="title_block">
    	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='View a top sellers products' mod='blockbestsellers'}">{l s='Top sellers' mod='blockbestsellers'}</a>
    </h4>
	<div class="block_content">
	{if $best_sellers && $best_sellers|@count > 0}
		<ul class="block_content products-block">
			{foreach from=$best_sellers item=product name=myLoop}
			<li class="clearfix">
				<a href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}" class="products-block-image content_img clearfix">
					<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'tm_small_default')|escape:'html'}" alt="{$product.legend|escape:'html':'UTF-8'}" />
				</a>
				<div class="product-content">
                	<h5>
                    	<a class="product-name" href="{$product.link|escape:'html'}" title="{$product.legend|escape:'html':'UTF-8'}">
                            {$product.name|strip_tags:'UTF-8'|escape:'html':'UTF-8'|truncate:40:'...'}
                        </a>
                    </h5>
                    <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>
                        </div>
                    {/if}
                </div>
			</li>
		{/foreach}
		</ul>
		<div class="lnk">
        	<a href="{$link->getPageLink('best-sales')|escape:'html'}" title="{l s='All best sellers' mod='blockbestsellers'}"  class="btn btn-default button button-small">
            	<span>
                	{l s='All best sellers' mod='blockbestsellers'}
                    <i class="icon-chevron-right right"></i>
               	</span>
            </a>
        </div>
	{else}
		<p>{l s='No best sellers at this time' mod='blockbestsellers'}</p>
	{/if}
	</div>
</div>
<!-- /MODULE Block best sellers -->

The file comes from: /themes/MYtheme/modules/blockbestsellers

Edited by Smiles (see edit history)
Link to comment
Share on other sites

First thanks for A-Z Hosting for the tips on reducing the count of best sellers. It indeed reduced the numbers to the required.

However, I need some tips on how to tweak it further

 

Home Page: Display all the Best-Sellers instead of the value fixed in the code

Sub Pages: Show limited for instance 4 only best sellers in the left column "Top Sellers Block"

 

Appreciate

Edited by yashman (see edit history)
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...