Lindsayanng Posted July 3, 2011 Share Posted July 3, 2011 This tutorial can actually work for any block that you would like to display more than one item in the list. For this instance I wanted to display two items in the specials block instead of one. Here is the code for my entire blockspecials.tpl - its the only file that needs changing: <!-- MODULE Block specials --> getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'} {if $special !== false} {foreach from=$special item='product' name='special'} {if $smarty.foreach.special.index < 2} {$special.name|escape:html:'UTF-8'} getImageLink($special.link_rewrite, $special.id_image, 'large')}" alt="{$special.legend|escape:html:'UTF-8'}" width="242px" title="{$special.name|escape:html:'UTF-8'}" /> was {if !$priceDisplay}{displayWtPrice p=$special.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if} {if $special.specific_prices} {assign var='specific_prices' value=$special.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <!--(-{$specific_prices.reduction * 100|floatval}%)--> {/if} {/if} Now {if !$priceDisplay}{displayWtPrice p=$special.price}{else}{displayWtPrice p=$special.price_tax_exc}{/if} {/if} {/foreach} getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="home_button">{l s='All specials' mod='blockspecials'} {else} {l s='No specials at this time' mod='blockspecials'} {/if} <!-- /MODULE Block specials --> A quick explanation: The only thing that needed to be done was to create a loop so that the code knows to go back and loop up the same information twice (or as many times as you tell it to). The loop is VERY simple. This is the start of the loop that tells it to look for the products with specials and then tells it to get 2 (you can change that number to whatever you want!!! {foreach from=$special item='product' name='special'} {if $smarty.foreach.special.index < 2} Place the above bit of code directly before the chunk that you want to be repeated. For instance if I have an HTML structure that has is this: PRODUCT INFO HERE And you want to repeat just the product info then you will place the first chunk of code directly before the so that it repeats the whole product info. If you wanted to repeat the entire list of products then you can place that chunk before the and you will get that whole area repeated. The next thing you have to do is simply close out that statement and tell it where to stop repeating. Use this: {/if} {/foreach} In the above example I would place that code directly after the So again, the simplified version of this code is: {foreach from=$special item='product' name='special'} {if $smarty.foreach.special.index < 2} PRODUCT INFO HERE {/if} {/foreach} ONE MORE NOTE: You can adapt this code for just about any block you want to. You will need to replace the $special and 'special' with the variable name for that block. You can find the function name by going to that block's .php page which would be found in modules/moduleblock/moduleblock.php (replace 'moduleblock' with the actual block name)Look for code that looks like this: $smarty->assign(array('special' => $special, Where ever you see $smarty->assign you will know that the code is assigning a variable to be used throughout the templates. So I hope this helps. Please feel free to jump in and correct me if something is wrong. I just hacked this together the best way I know how. I am not a prestashop [spam-filter] - just learning it. I do have enough experience with customizing carts to make changes like this and really like to share my stuff so that people can learn. 2 Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 3, 2011 Author Share Posted July 3, 2011 Ok after posting this I just realized one big issue.. Its repeating the content but its not repeating the query, therefore resulting in two of the same products and not one of each product that is a special. ANY THOUGHTS> Link to comment Share on other sites More sharing options...
shokinro Posted July 4, 2011 Share Posted July 4, 2011 you need to make sure that $special contains multiple entries of products.actually, i checked the block special module, it only get one record of special.this is line in blocksoecial.php file that load $special data if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang))) if you look into the function of getRandomSpecial() in Product class, you will see it only returns one record.so here is solution;you call two times the same function and set result into an array $specials, then you use the $specials at your tpl file, it should work. here is code on how to get two specials. $specials = array(); $specials[] = Product::getRandomSpecial(intval($params['cookie']->id_lang)); $specials[] = Product::getRandomSpecial(intval($params['cookie']->id_lang)); $smarty->assign('specials',$specials); 1 Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 4, 2011 Author Share Posted July 4, 2011 Sorry I'm really confused by your explaination. The code you are speaking about is this correct: public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; if (!$special = Product::getRandomSpecial((int)($params['cookie']->id_lang)) AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $smarty->assign(array('special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + $special['rate'] / 100), 2), 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockspecials.tpl'); } I can see it is getting a random special and then displaying the results of 'special' in an array.. I do not understand how your code fits in here/ Link to comment Share on other sites More sharing options...
bug00 Posted July 6, 2011 Share Posted July 6, 2011 awesome !!partner your solution is smart but if random send 2 times the same article...here a solution that works, not optimised, write fast but working : in classes/product.php (u can overide this class) add a methode public static function getRandomSpecialx($id_lang, $beginning = false, $ending = false,$nbr=1) { $currentDate = date('Y-m-d H:i:s'); $ids_product = self::_getProductIdByDate((!$beginning ? $currentDate : $beginning), (!$ending ? $currentDate : $ending)); $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); // Please keep 2 distinct queries because RAND() is an awful way to achieve this result $sql = ' SELECT p.id_product FROM `'._DB_PREFIX_.'product` p WHERE 1 AND p.`active` = 1 AND p.`id_product` IN ('.implode(', ', $ids_product).') AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sqlGroups.' ) ORDER BY RAND() limit 0,'.$nbr; $id_products = Db::getInstance()->ExecuteS($sql); if (count($id_products) == 0) return false; $row = array(); $i = 0; foreach ($id_products as $id_product) { $row[$i] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`) WHERE p.id_product = '.(int)$id_product[id_product]); $row[$i] = Product::getProductProperties($id_lang, $row[$i]); $i++; } return $row; } in module/blockspecials/blockspecials.phprewrite the code (or copye the prestashop module and do change on methode hookright) public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $special = Product::getRandomSpecialx((int)($params['cookie']->id_lang),false,false,2); if (count($special) == 0 AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize('medium') )); return $this->display(__FILE__, 'blockspecials.tpl'); } in blockspecials.tpl : <!-- MODULE Block specials --> getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'} {if $special|@count gt 0} {foreach from=$special item=item} getImageLink($item.link_rewrite, $item.id_image, 'medium')}" alt="{$item.legend|escape:html:'UTF-8'}" height="{$mediumSize.height}" width="{$mediumSize.width}" title="{$item.name|escape:html:'UTF-8'}" /> {$item.name|escape:html:'UTF-8'} {if !$priceDisplay}{displayWtPrice p=$item.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if} {if $item.specific_prices} {assign var='specific_prices' value=$item.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} (-{$specific_prices.reduction*100|floatval}%) {/if} {/if} {if !$priceDisplay}{displayWtPrice p=$item.price}{else}{displayWtPrice p=$item.price_tax_exc}{/if} {/foreach} getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="button_large">{l s='All specials' mod='blockspecials'} {else} {l s='No specials at this time' mod='blockspecials'} {/if} <!-- /MODULE Block specials --> 2 Link to comment Share on other sites More sharing options...
shokinro Posted July 6, 2011 Share Posted July 6, 2011 partner your solution is smart but if random send 2 times the same article yes are right, it could happens in some cases. thanks for sharing. Link to comment Share on other sites More sharing options...
shokinro Posted July 17, 2011 Share Posted July 17, 2011 for your reference, I just posted a sample code on following thread.http://www.prestashop.com/forums/viewthread/120012it is not the best way, but it works when you have large number of specials.you can improve it. Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 18, 2011 Author Share Posted July 18, 2011 @Bug00 - your code worked perfectly but had to fix a few typos. For anyone who comes across this thread in the future and gets errors that they don't know what to do with, here's the code from above with a few typos fixed: <!-- MODULE Block specials --> getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'} {if $special|@count gt 0} {foreach from=$special item=item} {$item.name|escape:html:'UTF-8'} getImageLink($special.link_rewrite, $item.id_image, 'large')}" alt="{$item.legend|escape:html:'UTF-8'}" height="138" width="246" title="{$item.name|escape:html:'UTF-8'}" /> {if !$priceDisplay}{displayWtPrice p=$item.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if} {if $item.specific_prices} {assign var='specific_prices' value=$item.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} (-{$specific_prices.reduction*100|floatval}%) {/if} {/if} {if !$priceDisplay}{displayWtPrice p=$item.price}{else}{displayWtPrice p=$item.price_tax_exc}{/if} {/foreach} getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="button_large">{l s='All specials' mod='blockspecials'} {else} {l s='No specials at this time' mod='blockspecials'} {/if} <!-- /MODULE Block specials --> Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 18, 2011 Author Share Posted July 18, 2011 Ok one more issue!!!!The price w/o discount is showing as $0.00 which means it's not actually receiving the value of the pricewithoutdiscount You can see here: http://bscdeveloper.com/hss/ Link to comment Share on other sites More sharing options...
ScubaLessonsInc Posted July 21, 2011 Share Posted July 21, 2011 I am really in need of a module for 1.4.25 that automatically shows more than one product special.. it could be like a left column featured products or like the product specials dont care but needs to show 2 or more. Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 21, 2011 Author Share Posted July 21, 2011 Well if you can wait till I launch this store that I am working on i will release the code as a patch to the existing specials block (or I can create a separate module) if you'd like Link to comment Share on other sites More sharing options...
ScubaLessonsInc Posted July 21, 2011 Share Posted July 21, 2011 I would totally love that module as I am sure others would too!.. thank you so much! Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 21, 2011 Author Share Posted July 21, 2011 Ok. i will bundle a bunch of my changes as modules as soon as I am done.. I am new to prestashop so turning these from mods to an actual module will be a little time, but not too much. Link to comment Share on other sites More sharing options...
[email protected] Posted July 30, 2011 Share Posted July 30, 2011 Hi, Bug00 i tried u r code adding in my files but is giving no result, but an error text like this getPageLink('prices-drop.php')}" title="Specials">Specials getImageLink($item.link_rewrite, $item.id_image, 'medium')}" alt="iPod Nano" height="80" width="80" title="iPod Nano" /> iPod Nano 187,19 Rs. (-5%) 177,83 Rs. getPageLink('prices-drop.php')}" title="All specials" class="button_large">All specials the code which we have added in tpl file in my front page can u pls explain me the steps and the code to be added in respective files pls again. iam using version 1.4.1 is that compatible for my version iam seeking all the images to appear in the Specials Block and using carousel for showing all the images. can u guide me. Anil Bangalore Link to comment Share on other sites More sharing options...
[email protected] Posted August 26, 2011 Share Posted August 26, 2011 Hello All, Iam a web developer and am designing a website for a toys store. So iam using Prestashop shopping cart version 1.4.1 iam totally new to the CMS and according to the requirements i need to display multiple specials (images) i.e more than 1 special in Specials Block i tried all u the code available in the forum but am not getting it. can any one give me a solution for achieving this please brief me all the required steps in doing this and make me complete my task please, THANKS IN ADVANCE. Link to comment Share on other sites More sharing options...
diana13 Posted November 4, 2011 Share Posted November 4, 2011 Has anyone tried to display more specials products in 1.4.5.1? The above code didn't work Link to comment Share on other sites More sharing options...
lakombrada Posted May 4, 2012 Share Posted May 4, 2012 edit only module files: http://www.prestashop.com/forums/topic/20501-how-do-i-add-more-than-1-special-in-the-blockspecials-module/page__st__20__p__818539?do=findComment&comment=818539 Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted September 7, 2012 Share Posted September 7, 2012 (edited) awesome !! partner your solution is smart but if random send 2 times the same article... here a solution that works, not optimised, write fast but working : in classes/product.php (u can overide this class) add a methode public static function getRandomSpecialx($id_lang, $beginning = false, $ending = false,$nbr=1) { $currentDate = date('Y-m-d H:i:s'); $ids_product = self::_getProductIdByDate((!$beginning ? $currentDate : $beginning), (!$ending ? $currentDate : $ending)); $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); // Please keep 2 distinct queries because RAND() is an awful way to achieve this result $sql = ' SELECT p.id_product FROM `'._DB_PREFIX_.'product` p WHERE 1 AND p.`active` = 1 AND p.`id_product` IN ('.implode(', ', $ids_product).') AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sqlGroups.' ) ORDER BY RAND() limit 0,'.$nbr; $id_products = Db::getInstance()->ExecuteS($sql); if (count($id_products) == 0) return false; $row = array(); $i = 0; foreach ($id_products as $id_product) { $row[$i] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`) WHERE p.id_product = '.(int)$id_product[id_product]); $row[$i] = Product::getProductProperties($id_lang, $row[$i]); $i++; } return $row; } in module/blockspecials/blockspecials.php rewrite the code (or copye the prestashop module and do change on methode hookright) public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $special = Product::getRandomSpecialx((int)($params['cookie']->id_lang),false,false,2); if (count($special) == 0 AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize('medium') )); return $this->display(__FILE__, 'blockspecials.tpl'); } in blockspecials.tpl : <!-- MODULE Block specials --> [b] [url=""]getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}[/url][/b] {if $special|@count gt 0} [list] {foreach from=$special item=item} [*] [url="{$item.link}"]<img />getImageLink($item.link_rewrite, $item.id_image, 'medium')}" alt="{$item.legend|escape:html:'UTF-8'}" height="{$mediumSize.height}" width="{$mediumSize.width}" title="{$item.name|escape:html:'UTF-8'}" />[/url] [*] [b] [url="{$item.link}"]{$item.name|escape:html:'UTF-8'}[/url][/b] {if !$priceDisplay}{displayWtPrice p=$item.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if} {if $item.specific_prices} {assign var='specific_prices' value=$item.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} (-{$specific_prices.reduction*100|floatval}%) {/if} {/if} {if !$priceDisplay}{displayWtPrice p=$item.price}{else}{displayWtPrice p=$item.price_tax_exc}{/if} {/foreach} [/list] [url=""]getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="button_large">{l s='All specials' mod='blockspecials'}[/url] {else} {l s='No specials at this time' mod='blockspecials'} {/if} <!-- /MODULE Block specials --> After correcting some missing bits of code from the solution above, I was able to get this to work with no duplicating of the products. However, it is only showing two special products. I see where it says to keep two distinct queries. I am assuming I would need to add more to show more special products? What do I need to edit to show more than two products? Like six products. Thanks! Edited September 7, 2012 by AFemaleProdigy (see edit history) 1 Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted September 14, 2012 Share Posted September 14, 2012 Anyone??? After correcting some missing bits of code from the solution above, I was able to get this to work with no duplicating of the products. However, it is only showing two special products. I see where it says to keep two distinct queries. I am assuming I would need to add more to show more special products? What do I need to edit to show more than two products? Like six products. Thanks! 1 Link to comment Share on other sites More sharing options...
jonsecu Posted November 27, 2012 Share Posted November 27, 2012 Hi... I am quite new to PS. I am looking for a way to check if the special (discount) of a product is due. Do you know where are the start and end date of a product´s special stored on the DB? Or how can I compare the end date with the current time for example? Thank you very much. Link to comment Share on other sites More sharing options...
spc Posted February 5, 2013 Share Posted February 5, 2013 hello... Now in my homefeatured i have 5 products... I whant to make the pricedrop like that one under the homefeatured. I have manage to do it like this: <!-- MODULE Pricedrop Products --> <div id="featured-products_block_center" class="home_products"> <h4>{l s='Reduce rims' mod='pricedrop'}</h4> {if isset($special) AND $special} <div class="block_content"> {assign var='liHeight' value=342} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$special|@count} {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} <ul style="height:{$ulHeight}px;"> {foreach from=$products item=product name=pricedrop} <li class="ajax_block_product {if $smarty.foreach.pricedrop.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}clear{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}"> <a class="products_block_img bordercolor" href="{$special.link}"><img src="{$link->getImageLink($special.link_rewrite, $special.id_image, 'home')}" alt="{$special.legend|escape:html:'UTF-8'}" title="{$special.name|escape:html:'UTF-8'}" /></a><div> <span class="price">{if $pricedrop.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}{if !$priceDisplay}{convertPrice price=$pricedrop.price}{else}{convertPrice price=$pricedrop.price_tax_exc}{/if}{/if}</span> {if $special.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$special.price}{else}{convertPrice price=$special.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if} <a class="button" href="{$special.link}" title="{l s='View' mod='pricedrop'}">{l s='View' mod='pricedrop'}</a> {if ($special.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $special.available_for_order AND !isset($restricted_country_mode) AND $special.minimal_quantity == 1 AND $special.customizable != 2 AND !$PS_CATALOG_MODE} {if ($special.quantity > 0 OR $special.allow_oosp)} <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$special.id_product}" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$special.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='pricedrop'}">{l s='Add to cart' mod='pricedrop'}</a> {else} <span class="exclusive">{l s='Add to cart' mod='pricedrop'}</span> {/if} {else} <div style="height:23px;"></div> {/if} </div> </li> {/foreach} </ul> </div> {else} <p>{l s='No specials at this time' mod='pricedrop'}</p> {/if} </div> <!-- MODULE Pricedrop Products --> I show the 2 one that i pricedrop, but i olso show the other one that is in the home category. Can some one help me please..... Link to comment Share on other sites More sharing options...
isaiaseg Posted April 11, 2013 Share Posted April 11, 2013 my question is this.. I have prestashop_1.5.4.0 and i'm trying to make visible more than 1 product, like 4 or 6, i tried everything and search for answers i the forum but nothing worked for me, maybe because the answers are for older versions of prestashop... please if you guys can help jus let me now, and sorry for my awful english.. thank you very much!! Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted April 15, 2013 Share Posted April 15, 2013 (edited) This is what I am using in my 1.4.7.3 store to show multiple specials (see attachment). Note that it will sometimes show the same item more than once and it lists them randomly. I have not been able to customize it any further. I also have not tried this with any newer PS versions, so I don't know if further modification would be required to make it work. Hope this helps. Change the file name blockspecials.txt to blockspecials.tpl For some reason, tpl files cannot be attached here. blockspecials.php blockspecials.txt You can see my use of this module here... http://www.rotmgvault.com Edited April 15, 2013 by AFemaleProdigy (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 16, 2013 Share Posted May 16, 2013 hello... Now in my homefeatured i have 5 products... I whant to make the pricedrop like that one under the homefeatured. I have manage to do it like this: <!-- MODULE Pricedrop Products --> <div id="featured-products_block_center" class="home_products"> <h4>{l s='Reduce rims' mod='pricedrop'}</h4> {if isset($special) AND $special} <div class="block_content"> {assign var='liHeight' value=342} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$special|@count} {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} <ul style="height:{$ulHeight}px;"> {foreach from=$products item=product name=pricedrop} <li class="ajax_block_product {if $smarty.foreach.pricedrop.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}clear{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}"> <a class="products_block_img bordercolor" href="{$special.link}"><img src="{$link->getImageLink($special.link_rewrite, $special.id_image, 'home')}" alt="{$special.legend|escape:html:'UTF-8'}" title="{$special.name|escape:html:'UTF-8'}" /></a><div> <span class="price">{if $pricedrop.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}{if !$priceDisplay}{convertPrice price=$pricedrop.price}{else}{convertPrice price=$pricedrop.price_tax_exc}{/if}{/if}</span> {if $special.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$special.price}{else}{convertPrice price=$special.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if} <a class="button" href="{$special.link}" title="{l s='View' mod='pricedrop'}">{l s='View' mod='pricedrop'}</a> {if ($special.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $special.available_for_order AND !isset($restricted_country_mode) AND $special.minimal_quantity == 1 AND $special.customizable != 2 AND !$PS_CATALOG_MODE} {if ($special.quantity > 0 OR $special.allow_oosp)} <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$special.id_product}" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$special.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='pricedrop'}">{l s='Add to cart' mod='pricedrop'}</a> {else} <span class="exclusive">{l s='Add to cart' mod='pricedrop'}</span> {/if} {else} <div style="height:23px;"></div> {/if} </div> </li> {/foreach} </ul> </div> {else} <p>{l s='No specials at this time' mod='pricedrop'}</p> {/if} </div> <!-- MODULE Pricedrop Products --> I show the 2 one that i pricedrop, but i olso show the other one that is in the home category. Can some one help me please..... there is speacial price drop property in product object. so if you look ar blockspecial module and copy that code and it will work only change smarty $special to $yourvariable Link to comment Share on other sites More sharing options...
fixgear Posted May 18, 2013 Share Posted May 18, 2013 hi AFemalProdigy. your hack seems perfect for me but i have applied it to my shop and it works fine but the big problem is that the images do not appear. note that i am using a non-default template (elation liquid). see attached "specialsblock.png" any ideas on how to fix this? thanks, jez... Link to comment Share on other sites More sharing options...
fixgear Posted May 18, 2013 Share Posted May 18, 2013 fixed it. i changed the... <a href="{$special.link}"><img src="{$link->getImageLink($special.link_rewrite, $special.id_image, 'medium')}" alt="{$special.legend| since i am using presta 1.5.3.1 i had to chage "medium" for "home_default" to call my image and not the image name for version 1.4.7.3 works great! thanks! jez... Link to comment Share on other sites More sharing options...
Bejo Posted July 5, 2013 Share Posted July 5, 2013 how do add more product display on module blockspecial? how do add more product display on module blockspecial? Link to comment Share on other sites More sharing options...
pdioana Posted July 16, 2013 Share Posted July 16, 2013 (edited) To modify the specials block to display more than 1 product (for PS 1.5.4.0.) I did so: Modified the getRandomSpecial function in classes/Product.php /** * Get a random special * * @param integer $id_lang Language id * @return array Special */ public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null) { if (!$context) $context = Context::getContext(); $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) $front = false; $current_date = date('Y-m-d H:i:s'); $product_reductions = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context, true); if ($product_reductions) { $ids_product = ' AND ('; foreach ($product_reductions as $product_reduction) $ids_product .= '( product_shop.`id_product` = '.(int)$product_reduction['id_product'].($product_reduction['id_product_attribute'] ? ' AND product_attribute_shop.`id_product_attribute`='.(int)$product_reduction['id_product_attribute'] :'').') OR'; $ids_product = rtrim($ids_product, 'OR').')'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); // Please keep 2 distinct queries because RAND() is an awful way to achieve this result $sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (product_shop.id_product = pa.id_product) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').' WHERE product_shop.`active` = 1 '.(($ids_product) ? $ids_product : '').' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sql_groups.' ) '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' AND p.`id_category_default` != 199 GROUP BY product_shop.id_product ORDER BY RAND() LIMIT 0,3'; // LIMIT the number of products to show (3 in this case) $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); foreach($result as $res){ if($res['id_product']){ $sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON ( p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' ) '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') '.Product::sqlStock('p', 0).' WHERE p.id_product = '.(int)$res['id_product'].' GROUP BY product_shop.id_product'; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if($row){ if ($res['id_product_attribute']){ $row['id_product_attribute'] = $res['id_product_attribute']; } $spe[] = Product::getProductProperties($id_lang, $row); } } } return $spe; } else return false; } In Themes/Your_theme_name/Modules/blockspecials/blockspecials.tpl (I modified what it's marked) <!-- MODULE Block specials --> <div id="special_block_right" class="block products_block exclusive blockspecials"> <h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></h4> <div class="block_content"> {if $special} {foreach from=$special item='product' name='special'} <ul class="products"> <li class="ajax_block_product"> <a class="product_image" href="{$product.link}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:html:'UTF-8'}" title="{$product.name|escape:html:'UTF-8'}" /></a> <div> <span class="addtocart"><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="button_large">{l s='All specials' mod='blockspecials'}</a></span> </div> <h3><a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}">{$product.name|escape:html:'UTF-8'}</a></h3> <p class="product_desc">{$product.description_short|truncate:120:'...'|strip_tags:'UTF-8'}</p> <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span> {if $product.specific_prices} {assign var='specific_prices' value=$product.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <span class="reduction">(-{$specific_prices.reduction * 100|floatval}%)</span> {/if} {/if} <span class="price">{if !$priceDisplay}{displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc}{/if}</span> </li> </ul> {/foreach} {else} <p>{l s='No specials at this time' mod='blockspecials'}</p> {/if} </div> </div> <!-- /MODULE Block specials --> Edited July 16, 2013 by pdioana (see edit history) 3 Link to comment Share on other sites More sharing options...
no1nick Posted August 1, 2013 Share Posted August 1, 2013 (edited) Oki doki, my idea might be helpful also it works. Just use getPricesDrop function and mix specials module with homefeatured like i did in your specials.php. You can also make from homefeatured new specials by changing some stuff which you can find below: $nb = (int)(Configuration::get('HOME_FEATURED_NBR')); $special = Product::getPricesDrop((int)Context::getContext()->language->id,0,($nb ? $nb : 10)); $this->smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), $nb is a variable in which i store the quantity of products to be displayed. Ok, than just copy {foreach}...{/foreach} from homefeatured.tpl. {if $special} {assign var='liHeight' value=250} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$special|@count} {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} <ul style="height:{$ulHeight}px;"> {foreach from=$special item=product name=special} {math equation="(total%perLine)" total=$smarty.foreach.special.total perLine=$nbItemsPerLine assign=totModulo} {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if} <li class="product_imageajax_block_product {if $smarty.foreach.special.first}first_item{elseif $smarty.foreach.special.last}last_item{else}item{/if} {if $smarty.foreach.special.iteration%$nbItemsPerLine == 0}last_item_of_line {elseif $smarty.foreach.special.iteration%$nbItemsPerLine == 1} {/if} {if $smarty.foreach.special.iteration > ($smarty.foreach.special.total - $totModulo)}last_line{/if}"> I hope it'll help somebody. Edited August 1, 2013 by no1nick (see edit history) Link to comment Share on other sites More sharing options...
MojiOS Posted August 4, 2013 Share Posted August 4, 2013 To modify the specials block to display more than 1 product (for PS 1.5.4.0.) I did so: Modified the getRandomSpecial function in classes/Product.php /** * Get a random special * * @param integer $id_lang Language id * @return array Special */ public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null) { if (!$context) $context = Context::getContext(); $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) $front = false; $current_date = date('Y-m-d H:i:s'); $product_reductions = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context, true); if ($product_reductions) { $ids_product = ' AND ('; foreach ($product_reductions as $product_reduction) $ids_product .= '( product_shop.`id_product` = '.(int)$product_reduction['id_product'].($product_reduction['id_product_attribute'] ? ' AND product_attribute_shop.`id_product_attribute`='.(int)$product_reduction['id_product_attribute'] :'').') OR'; $ids_product = rtrim($ids_product, 'OR').')'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); // Please keep 2 distinct queries because RAND() is an awful way to achieve this result $sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (product_shop.id_product = pa.id_product) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').' WHERE product_shop.`active` = 1 '.(($ids_product) ? $ids_product : '').' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sql_groups.' ) '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' AND p.`id_category_default` != 199 GROUP BY product_shop.id_product ORDER BY RAND() LIMIT 0,3'; // LIMIT the number of products to show (3 in this case) $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); foreach($result as $res){ if($res['id_product']){ $sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON ( p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' ) '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') '.Product::sqlStock('p', 0).' WHERE p.id_product = '.(int)$res['id_product'].' GROUP BY product_shop.id_product'; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if($row){ if ($res['id_product_attribute']){ $row['id_product_attribute'] = $res['id_product_attribute']; } $spe[] = Product::getProductProperties($id_lang, $row); } } } return $spe; } else return false; } This code works. but I have a problem. The price without reduction just show 0 for all products. please help for fix it Link to comment Share on other sites More sharing options...
jemmeli Posted September 1, 2013 Share Posted September 1, 2013 (edited) Pdioana I copy and paste your code for the prestashop 1.5 but I have got the following problem: Undefined index: price_without_reduction (C:\xampp\htdocs\t-shirt_cus\modules\blockspecials\blockspecials.php, line 94)[/color] [color=#000000]how can I fix this I dont know from when comes the "[/color][color=#000000]price_without_reduction" index I check all the tables database related to this sql but i did not found any fields with the name of [/color][color=#000000]"[/color][color=#000000]price_without_reduction"[/color] Edited September 1, 2013 by jemmeli (see edit history) 1 Link to comment Share on other sites More sharing options...
mdazhar Posted September 17, 2013 Share Posted September 17, 2013 Module Special products display 2 or more products?.. How to avoid Duplicate product in special block...tell me guys.. ...very urgent... Regards azhar Link to comment Share on other sites More sharing options...
mdazhar Posted September 17, 2013 Share Posted September 17, 2013 After correcting some missing bits of code from the solution above, I was able to get this to work with no duplicating of the products. However, it is only showing two special products. I see where it says to keep two distinct queries. I am assuming I would need to add more to show more special products? What do I need to edit to show more than two products? Like six products. Thanks! Hai mam... Pls send me code for add multiple special blockspecial .. Not Repeat product in special block... Regards Azharudeen Link to comment Share on other sites More sharing options...
benvit Posted October 7, 2013 Share Posted October 7, 2013 hi, is there anyone who uses the block special offers by viewing more products for prestashop 1.5.you can post it.thanks Link to comment Share on other sites More sharing options...
cerovic Posted October 7, 2013 Share Posted October 7, 2013 (edited) hi, is there anyone who uses the block special offers by viewing more products for prestashop 1.5. you can post it. thanks I am using this on PS 1.5.4.0 . It is based on AFemaleProdigy solution on 1.4.7.3. I just changed the picture size to solid sizes (75 px). It is just need to design it in CSS (as anybody wish), but it works. The only problem is the product duplication in this block. I am not PHP coder, so no idea what to do. Anybody any ideas? blockspecials.zip Edited October 7, 2013 by cerkoxxl (see edit history) 1 Link to comment Share on other sites More sharing options...
kratek Posted November 6, 2013 Share Posted November 6, 2013 up Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 16, 2013 Share Posted December 16, 2013 Please friends how I can recover the time value from {html_select_time prefix='startTime_' use_24_hours=true display_seconds=false minute_interval=15} in the tpl file to my phpcontroller... Please .. Link to comment Share on other sites More sharing options...
abombazza Posted January 18, 2014 Share Posted January 18, 2014 hi, i also have prestashop 1.5 I need of this block with more of one product. I try to edit single file but the module doesn't work. Anyone help us ? thank you in advance Link to comment Share on other sites More sharing options...
LauraPresta Posted April 9, 2014 Share Posted April 9, 2014 HERE IS HOW TO EASY SHUFFLE SPECIALS PRODUCTS : in specialsblock.php you have to add : shuffle($specials); just after that $specials were filled, for exemple i had to add it here : << if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random))) { if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; shuffle($specials); $this->smarty->assign(array( 'specials' => $specials, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), )); } >> ( . Y . ) 1 Link to comment Share on other sites More sharing options...
marcellolaforgia Posted May 29, 2014 Share Posted May 29, 2014 I am using prestashop 1.6 and I can not find some correspondences with the codes you have entered. So I carry them below: blockspecials.tpl <!-- MODULE Block specials --> <div id="special_block_right" class="block"> <p class="title_block"> <a href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='Specials' mod='blockspecials'}"> {l s='Products in promotion' mod='blockspecials'} </a> </p> <div class="block_content products-block"> {if $special} <ul> <li class="clearfix"> <a class="products-block-image" href="{$special.link|escape:'html':'UTF-8'}"> <img class="replace-2x img-responsive" src="{$link->getImageLink($special.link_rewrite, $special.id_image, 'small_default')|escape:'html':'UTF-8'}" alt="{$special.legend|escape:'html':'UTF-8'}" title="{$special.name|escape:'html':'UTF-8'}" /> </a> <div class="product-content"> <h5> <a class="product-name" href="{$special.link|escape:'html':'UTF-8'}" title="{$special.name|escape:'html':'UTF-8'}"> {$special.name|escape:'html':'UTF-8'} </a> </h5> {if isset($special.description_short) && $special.description_short} <p class="product-description"> {$special.description_short|strip_tags:'UTF-8'|truncate:40} </p> {/if} <div class="price-box"> {if !$PS_CATALOG_MODE} <span class="price special-price"> {if !$priceDisplay} {displayWtPrice p=$special.price}{else}{displayWtPrice p=$special.price_tax_exc} {/if} </span> {if $special.specific_prices} {assign var='specific_prices' value=$special.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <span class="price-percent-reduction">-{$specific_prices.reduction*100|floatval}%</span> {/if} {/if} <span class="old-price"> {if !$priceDisplay} {displayWtPrice p=$special.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl} {/if} </span> {/if} </div> </div> </li> </ul> <div> <a class="btn btn-default button button-small" href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='All specials' mod='blockspecials'}"> <span>{l s='All specials' mod='blockspecials'}<i class="icon-chevron-right right"></i></span> </a> </div> {else} <div>{l s='No specials at this time.' mod='blockspecials'}</div> {/if} </div> </div> <!-- /MODULE Block specials --> blockspecials.php if (!defined('_PS_VERSION_')) exit; class BlockSpecials extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'blockspecials'; $this->tab = 'pricing_promotion'; $this->version = '1.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Specials block'); $this->description = $this->l('Adds a block displaying your current discounted products.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } public function install() { if (!Configuration::get('BLOCKSPECIALS_NB_CACHES')) Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', 20); $this->_clearCache('blockspecials.tpl'); $success = ( parent::install() && $this->registerHook('header') && $this->registerHook('addproduct') && $this->registerHook('updateproduct') && $this->registerHook('deleteproduct') ); if ($success) { // Hook the module either on the left or right column $theme = new Theme(Context::getContext()->shop->id_theme); if ((!$theme->default_right_column || !$this->registerHook('rightColumn')) && (!$theme->default_left_column || !$this->registerHook('leftColumn'))) { // If there are no colums implemented by the template, throw an error and uninstall the module $this->_errors[] = $this->l('This module need to be hooked in a column and your theme does not implement one'); parent::uninstall(); return false; } } return $success; } public function uninstall() { $this->_clearCache('blockspecials.tpl'); return parent::uninstall(); } public function getContent() { $output = ''; if (Tools::isSubmit('submitSpecials')) { Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY')); Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', (int)Tools::getValue('BLOCKSPECIALS_NB_CACHES')); $output .= $this->displayConfirmation($this->l('Settings updated')); } return $output.$this->renderForm(); } public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return; // We need to create multiple caches because the products are sorted randomly $random = date('Ymd').'|'.round(rand(4, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 4))); if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random))) { if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $this->smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), )); } return $this->display(__FILE__, 'blockspecials.tpl', (Configuration::get('BLOCKSPECIALS_NB_CACHES') ? $this->getCacheId('blockspecials|'.$random) : null)); } public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookHeader($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; $this->context->controller->addCSS(($this->_path).'blockspecials.css', 'all'); } public function hookAddProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function hookUpdateProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function hookDeleteProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Always display this block'), 'name' => 'PS_BLOCK_SPECIALS_DISPLAY', 'desc' => $this->l('Show the block even if no products are available.'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Number of cached files'), 'name' => 'BLOCKSPECIALS_NB_CACHES', 'desc' => $this->l('Specials are displayed randomly on the front-end, but since it takes a lot of ressources, it is better to cache the results. The cache is reset daily. 0 will disable the cache.'), ), ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'submitSpecials'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'PS_BLOCK_SPECIALS_DISPLAY' => Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')), 'BLOCKSPECIALS_NB_CACHES' => Tools::getValue('BLOCKSPECIALS_NB_CACHES', Configuration::get('BLOCKSPECIALS_NB_CACHES')), ); } } Can you tell me the changes to be done to bring up more than one product? The module is inserted in the left column (www.xanthe.it). thanks 1 Link to comment Share on other sites More sharing options...
NemoPS Posted May 29, 2014 Share Posted May 29, 2014 Have you tried this? http://nemops.com/product-list-prestashop-specials-module/#.U4butvna6r0 Basically, you need to edit the hook method 1 Link to comment Share on other sites More sharing options...
marcellolaforgia Posted May 29, 2014 Share Posted May 29, 2014 Dear Nemo, I followed step by step directions of the link that you have shown me, but unfortunately I did not get any results, even unloading the driver and reinstalling it. Could you help me? Link to comment Share on other sites More sharing options...
servanz Posted August 28, 2014 Share Posted August 28, 2014 Hi, i need help whith this problem, i use PS 1.6. Any Module?. Or everyone that know resolve this case in PS 1.6. Thanks for help. Link to comment Share on other sites More sharing options...
yaelweb Posted August 30, 2014 Share Posted August 30, 2014 To modify the specials block to display more than 1 product (for PS 1.5.4.0.) I did so: Modified the getRandomSpecial function in classes/Product.php /** * Get a random special * * @param integer $id_lang Language id * @return array Special */ public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null) { if (!$context) $context = Context::getContext(); $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) $front = false; $current_date = date('Y-m-d H:i:s'); $product_reductions = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context, true); if ($product_reductions) { $ids_product = ' AND ('; foreach ($product_reductions as $product_reduction) $ids_product .= '( product_shop.`id_product` = '.(int)$product_reduction['id_product'].($product_reduction['id_product_attribute'] ? ' AND product_attribute_shop.`id_product_attribute`='.(int)$product_reduction['id_product_attribute'] :'').') OR'; $ids_product = rtrim($ids_product, 'OR').')'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); // Please keep 2 distinct queries because RAND() is an awful way to achieve this result $sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (product_shop.id_product = pa.id_product) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1').' WHERE product_shop.`active` = 1 '.(($ids_product) ? $ids_product : '').' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sql_groups.' ) '.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').' AND p.`id_category_default` != 199 GROUP BY product_shop.id_product ORDER BY RAND() LIMIT 0,3'; // LIMIT the number of products to show (3 in this case) $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); foreach($result as $res){ if($res['id_product']){ $sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON ( p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' ) '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') '.Product::sqlStock('p', 0).' WHERE p.id_product = '.(int)$res['id_product'].' GROUP BY product_shop.id_product'; $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if($row){ if ($res['id_product_attribute']){ $row['id_product_attribute'] = $res['id_product_attribute']; } $spe[] = Product::getProductProperties($id_lang, $row); } } } return $spe; } else return false; } In Themes/Your_theme_name/Modules/blockspecials/blockspecials.tpl (I modified what it's marked) <!-- MODULE Block specials --> <div id="special_block_right" class="block products_block exclusive blockspecials"> <h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></h4> <div class="block_content"> {if $special} {foreach from=$special item='product' name='special'} <ul class="products"> <li class="ajax_block_product"> <a class="product_image" href="{$product.link}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:html:'UTF-8'}" title="{$product.name|escape:html:'UTF-8'}" /></a> <div> <span class="addtocart"><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}" class="button_large">{l s='All specials' mod='blockspecials'}</a></span> </div> <h3><a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}">{$product.name|escape:html:'UTF-8'}</a></h3> <p class="product_desc">{$product.description_short|truncate:120:'...'|strip_tags:'UTF-8'}</p> <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span> {if $product.specific_prices} {assign var='specific_prices' value=$product.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <span class="reduction">(-{$specific_prices.reduction * 100|floatval}%)</span> {/if} {/if} <span class="price">{if !$priceDisplay}{displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc}{/if}</span> </li> </ul> {/foreach} {else} <p>{l s='No specials at this time' mod='blockspecials'}</p> {/if} </div> </div> <!-- /MODULE Block specials --> I am using prestashop 1.6 and I can not find some correspondences with the codes you have entered. So I carry them below: blockspecials.tpl <!-- MODULE Block specials --> <div id="special_block_right" class="block"> <p class="title_block"> <a href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='Specials' mod='blockspecials'}"> {l s='Products in promotion' mod='blockspecials'} </a> </p> <div class="block_content products-block"> {if $special} <ul> <li class="clearfix"> <a class="products-block-image" href="{$special.link|escape:'html':'UTF-8'}"> <img class="replace-2x img-responsive" src="{$link->getImageLink($special.link_rewrite, $special.id_image, 'small_default')|escape:'html':'UTF-8'}" alt="{$special.legend|escape:'html':'UTF-8'}" title="{$special.name|escape:'html':'UTF-8'}" /> </a> <div class="product-content"> <h5> <a class="product-name" href="{$special.link|escape:'html':'UTF-8'}" title="{$special.name|escape:'html':'UTF-8'}"> {$special.name|escape:'html':'UTF-8'} </a> </h5> {if isset($special.description_short) && $special.description_short} <p class="product-description"> {$special.description_short|strip_tags:'UTF-8'|truncate:40} </p> {/if} <div class="price-box"> {if !$PS_CATALOG_MODE} <span class="price special-price"> {if !$priceDisplay} {displayWtPrice p=$special.price}{else}{displayWtPrice p=$special.price_tax_exc} {/if} </span> {if $special.specific_prices} {assign var='specific_prices' value=$special.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <span class="price-percent-reduction">-{$specific_prices.reduction*100|floatval}%</span> {/if} {/if} <span class="old-price"> {if !$priceDisplay} {displayWtPrice p=$special.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl} {/if} </span> {/if} </div> </div> </li> </ul> <div> <a class="btn btn-default button button-small" href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='All specials' mod='blockspecials'}"> <span>{l s='All specials' mod='blockspecials'}<i class="icon-chevron-right right"></i></span> </a> </div> {else} <div>{l s='No specials at this time.' mod='blockspecials'}</div> {/if} </div> </div> <!-- /MODULE Block specials --> blockspecials.php if (!defined('_PS_VERSION_')) exit; class BlockSpecials extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'blockspecials'; $this->tab = 'pricing_promotion'; $this->version = '1.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Specials block'); $this->description = $this->l('Adds a block displaying your current discounted products.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } public function install() { if (!Configuration::get('BLOCKSPECIALS_NB_CACHES')) Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', 20); $this->_clearCache('blockspecials.tpl'); $success = ( parent::install() && $this->registerHook('header') && $this->registerHook('addproduct') && $this->registerHook('updateproduct') && $this->registerHook('deleteproduct') ); if ($success) { // Hook the module either on the left or right column $theme = new Theme(Context::getContext()->shop->id_theme); if ((!$theme->default_right_column || !$this->registerHook('rightColumn')) && (!$theme->default_left_column || !$this->registerHook('leftColumn'))) { // If there are no colums implemented by the template, throw an error and uninstall the module $this->_errors[] = $this->l('This module need to be hooked in a column and your theme does not implement one'); parent::uninstall(); return false; } } return $success; } public function uninstall() { $this->_clearCache('blockspecials.tpl'); return parent::uninstall(); } public function getContent() { $output = ''; if (Tools::isSubmit('submitSpecials')) { Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY')); Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', (int)Tools::getValue('BLOCKSPECIALS_NB_CACHES')); $output .= $this->displayConfirmation($this->l('Settings updated')); } return $output.$this->renderForm(); } public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return; // We need to create multiple caches because the products are sorted randomly $random = date('Ymd').'|'.round(rand(4, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 4))); if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random))) { if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $this->smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), )); } return $this->display(__FILE__, 'blockspecials.tpl', (Configuration::get('BLOCKSPECIALS_NB_CACHES') ? $this->getCacheId('blockspecials|'.$random) : null)); } public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookHeader($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; $this->context->controller->addCSS(($this->_path).'blockspecials.css', 'all'); } public function hookAddProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function hookUpdateProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function hookDeleteProduct($params) { $this->_clearCache('blockspecials.tpl'); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Always display this block'), 'name' => 'PS_BLOCK_SPECIALS_DISPLAY', 'desc' => $this->l('Show the block even if no products are available.'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Number of cached files'), 'name' => 'BLOCKSPECIALS_NB_CACHES', 'desc' => $this->l('Specials are displayed randomly on the front-end, but since it takes a lot of ressources, it is better to cache the results. The cache is reset daily. 0 will disable the cache.'), ), ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'submitSpecials'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'PS_BLOCK_SPECIALS_DISPLAY' => Tools::getValue('PS_BLOCK_SPECIALS_DISPLAY', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')), 'BLOCKSPECIALS_NB_CACHES' => Tools::getValue('BLOCKSPECIALS_NB_CACHES', Configuration::get('BLOCKSPECIALS_NB_CACHES')), ); } } Can you tell me the changes to be done to bring up more than one product? The module is inserted in the left column (www.xanthe.it). thanks Gracias me sirvió, hay que modificar esos 2 archivos como dices Excelente !!! Sirve para la versión 1.6 --------------------- Thanks helped me, you have to modify these 2 files as you say Excellent !!! Used to version 1.6 Link to comment Share on other sites More sharing options...
yaelweb Posted August 30, 2014 Share Posted August 30, 2014 Comparto mi código para obtener en forma de grid el listado, se agregò la clase al li <li class="ajax_block_product col-xs-12 col-sm-6 col-md-4 first-in-line last-line first-item-of-tablet-line first-item-of-mobile-line last-mobile-line hovered"> In Themes/Your_theme_name/Modules/blockspecials/blockspecials.tpl Saludos !!!! {** 2007-2014 PrestaShop** NOTICE OF LICENSE** This source file is subject to the Academic Free License (AFL 3.0)* that is bundled with this package in the file LICENSE.txt.* It is also available through the world-wide-web at this URL:* http://opensource.org/licenses/afl-3.0.php* If you did not receive a copy of the license and are unable to* obtain it through the world-wide-web, please send an email* to [email protected] so we can send you a copy immediately.** DISCLAIMER** Do not edit or add to this file if you wish to upgrade PrestaShop to newer* versions in the future. If you wish to customize PrestaShop for your* needs please refer to http://www.prestashop.com for more information.** @author PrestaShop SA <[email protected]>* @copyright 2007-2014 PrestaShop SA* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)* International Registered Trademark & Property of PrestaShop SA*} <!-- MODULE Block specials --><div id="special_block_right" class="block_rodin"><h3 class="title_block"> <img class="replace-2x" src="http://localhost/rodin/img/cms/icono_naranja.png" alt="" width="75" height="103"> <a href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='Specials' mod='blockspecials'}"> {l s='Specials' mod='blockspecials'} </a> </h3><div class="block_content products-block"> {if $special} <ul> {foreach from=$special item='product' name='special'} <li class="ajax_block_product col-xs-12 col-sm-6 col-md-4 first-in-line last-line first-item-of-tablet-line first-item-of-mobile-line last-mobile-line hovered"> <a class="products-block-image" href="{$product.link|escape:'html':'UTF-8'}"> <img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{$product.legend|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" /> </a> <div class="right-block"> <h5> <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}"> {$product.name|escape:'html':'UTF-8'} </a> </h5> {if isset($product.description_short) && $product.description_short} <p class="product-description"> {$product.description_short|strip_tags:'UTF-8'|truncate:40} </p> {/if} <div class="price-box"> {if !$PS_CATALOG_MODE} <span class="price special-price"> {if !$priceDisplay} {displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc} {/if} </span> {if $product.specific_prices} {assign var='specific_prices' value=$product.specific_prices} {if $specific_prices.reduction_type == 'percentage' && ($specific_prices.from == $specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $specific_prices.from))} <span class="price-percent-reduction">-{$specific_prices.reduction*100|floatval}%</span> {/if} {/if} <span class="old-price"> {if !$priceDisplay} {displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl} {/if} </span> {/if} </div> </div> </li>{/foreach} </ul> <div><a class="btn btn-default button button-small" href="{$link->getPageLink('prices-drop')|escape:'html':'UTF-8'}" title="{l s='All specials' mod='blockspecials'}"> <span>{l s='All specials' mod='blockspecials'}<i class="icon-chevron-right right"></i></span> </a></div> {else}<div>{l s='No specials at this time.' mod='blockspecials'}</div> {/if}</div></div><!-- /MODULE Block specials --> Link to comment Share on other sites More sharing options...
DARKF3D3 Posted January 2, 2015 Share Posted January 2, 2015 Hi all, I'm showing multiple products with price reduction on block special. The problem it's that it always show the same products (with higher discount), do you know if there's a way to show products at random? Link to comment Share on other sites More sharing options...
kush4133 Posted November 25, 2015 Share Posted November 25, 2015 After correcting some missing bits of code from the solution above, I was able to get this to work with no duplicating of the products. However, it is only showing two special products. I see where it says to keep two distinct queries. I am assuming I would need to add more to show more special products? What do I need to edit to show more than two products? Like six products. Thanks! nice Link to comment Share on other sites More sharing options...
Recommended Posts