Jump to content

Blockspecials: how to display four products in home page with 1.6?


Recommended Posts

Hello everyone,

 

I have a 'simple' question: how can I modify the base Blockspecials module in order to display four products (not one as in default) horizontally in the home page?

I am using Prestashop 1.6 and I am trying to modify the default-bootstrap theme.

 

Thanks! :D

Link to comment
Share on other sites

it's not default behaviour if you see only one product.

this blocks shows 4 products by default

 

you've got more specials in shop? (specials = product with defined special price)

 

Thanks you for your reply!

I have installed Prestashop 1.6.0.6 on my computer (using apache and mysql) and I have not deleted nor modified yet the default products (women dresses). There are two dresses on sale but I only see one of them (at random) on the specials block.

 

I added this code to file /modules/blockspecials/blockspecials.php:

	public function hookDisplayHome($params)
	{
		return $this->hookRightColumn($params);
	}

and now I am able to position the block on the homepage but I guess this is not enough to show four products... :P

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

ahh my bad you're talking about bestsellers module, i just thought that you're talking about other addon. sorry for the confusion.

 

this module doesnt support displayHome hook unfortunately, the way of how you're trying to transplant it is not so good because right column displays only one picture.

 

you can try to use the way of how pictures appearing in homepage featured module, you can copy code of tpl file :)

Link to comment
Share on other sites

  • 2 weeks later...

Display 10 specials in block special in prestashop 1.5.6.1

 

in /themes/your_theme/modules/blockspecials/blockspecials.tpl

 

change line

{if $specials}
        <ul> {foreach from=$specials item=special}

+

				</div>
			</li>{/foreach}
		</ul>

and in file /modules/blockspecials/blockspecials.php

 

line

        {
             if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 10)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) // 0, 10 value displayed items
return;

$this->smarty->assign(array(
'specials' => $specials,

Heureka

 

f7c36e5a93ab7960-2.jpg

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

Hello and thank you for your reply,

 

at the end I used your suggestion to implement another solution.

Since I wanted to display the special products in home page and to make them appear in the same way as the featured products, I modified one of the existing modules in order to display several special products in home page.

 

I decided to sacrify the "new products" block and I have pasted below the lines I inserted in the blocknewproducts.php file.

I hope this can be useful to someone else!

 

Thanks to the repliers, I will sign the thread as 'solved' now.

	public function hookdisplayHomeTabContent($params)
	{
		if (!$this->isCached('blocknewproducts_home.tpl', $this->getCacheId('blocknewproducts-home')))
		{
// 			$this->smarty->assign(array(
// 				'new_products' => BlockNewProducts::$cache_new_products,
// 				'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
// 				'homeSize' => Image::getSize(ImageType::getFormatedName('home'))
// 			));
			if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
				return;

			$this->smarty->assign(array(
				'new_products' => $specials,
				'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
				'homeSize' => Image::getSize(ImageType::getFormatedName('home'))
			));
		}

		if (BlockNewProducts::$cache_new_products === false)
			return false;

		return $this->display(__FILE__, 'blocknewproducts_home.tpl', $this->getCacheId('blocknewproducts-home'));
	}
Link to comment
Share on other sites

  • 10 months 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...