Rajesh Kumar Yadav Posted August 9, 2013 Share Posted August 9, 2013 (edited) As per this topic http://www.prestasho...in-new-product/ Now I want to know how to can show 4 products in special block, currently it is showing 1. However I have added some products as giving them discount by percent and by amount for some. When I click All Special hyperlink then on next page these special products are visible, then why not on home page? Edited August 9, 2013 by PascalVG (see edit history) Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) I have tried {foreach from=$special item='product' name='special'} {if $smarty.foreach.special.index < 4} PRODUCT INFO HERE {/if} {/foreach} Then out put is It is showing 4 items now but all images are same all products are same...so it is use less. When I refresh page then it changes the products but again all 4 are same. I want to have all 4 special products without repeating as above. Edited August 9, 2013 by rajesh.yadav (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 9, 2013 Share Posted August 9, 2013 Need to edit the source files. At the moment it shows only 1 random special. It was most probably meant to be used on the side columns, where space is limited. Did someone ever do this already?? pascal Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 I did it actually, but you have to use another query in the source php file. You can try with Product::getPricesDrop($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, $beginning = false, $ending = false, Context $context = null) Cheers! Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 This is my code in file blockspecial.php I have created a new hook by this it is being displayed on center column on home page. Now please let me know where should I have to put your code in my existing code shown below: public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; 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), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($specials =Product::getPricesDrop($this->context->language->id,0,10)) return; $this->smarty->assign(array( 'specials' => $specials, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } 1 Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 Now my site is now working it is showing white page after applying above code. So I tried if (!($special =Product::getPricesDrop($this->context->language->id,0,10)) instead of your if (!($specials =Product::getPricesDrop($this->context->language->id,0,10)) but still white page. So I am undoing your code. Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 Oh, I missed a closing ) at the end, sorry Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 Now it is saying No product specials are available at this time. Now what should I have to do? Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 But did you refer to $specials instead of $special in the tpl file? As you can see i renamed the variable to be more meaningful Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($specials =Product::getPricesDrop($this->context->language->id,0,10))) return; $this->smarty->assign(array( 'specials' => $specials, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } what should I write special or specials? I've applied above code, am I making mistake? Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 in the template, $specials, and use a foreach to loop through them Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 If I'm using special then output is So now what should I've to use? How products will be visible? Link to comment Share on other sites More sharing options...
NemoPS Posted August 9, 2013 Share Posted August 9, 2013 as I said, $specials uh, but do you know how to edit a template? You should definitely go through the basics if you don't or you'll never get to the expected result this way Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) Sorry but I've completed only 1 project in prestashop. I am magento developer, Prestashop is new for me. If I use special then it is showing view buttons and they're working fine. then why thumb images are not being displayed. anyway I dont know what should I have to do now Edited August 9, 2013 by rajesh.yadav (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 9, 2013 Share Posted August 9, 2013 Quote: public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($specials =Product::getPricesDrop($this->context->language->id,0,10))) return; $this->smarty->assign(array( 'specials' => $specials, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } Mixing up your vars don't work in either Prestashop nor Magento ;-) Change red $special in $specials And see if this brings us further pascal Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) Did it but still it says No product specials are available at this time. Then I gone through product>prices>and changed the start date to yesterday i.e. 8August 2013 to 31Aug2013 Even I had put $special in tpl but still not working, But nothing happened. I thought current date might be issue. Edited August 9, 2013 by rajesh.yadav (see edit history) Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 9, 2013 Author Share Posted August 9, 2013 Yes I did it I just changed $special variable to $product and now its working fine as I was desiring. Link to comment Share on other sites More sharing options...
PascalVG Posted August 9, 2013 Share Posted August 9, 2013 Hi Rajesh, Nice that it works now. To help others may they ever want to change this as well, can you copy your final code and file name(s) that you've changed here? Thanks! pascal Link to comment Share on other sites More sharing options...
jahidulewu Posted August 11, 2013 Share Posted August 11, 2013 in my localhost specials works fine but single product. But in my server it is not working, I dont know why? here is my address. http://www.realamberjewelry.com/ anybody please help. Link to comment Share on other sites More sharing options...
vekia Posted August 11, 2013 Share Posted August 11, 2013 where i can find url to the specials or specials block? i don't see it on your website Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 12, 2013 Author Share Posted August 12, 2013 As you have supported me so as per your request I'm sharing here my code snippet for blockspecial.tpl [full page code] {* * 2007-2013 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-2013 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 products_block exclusive blockspecials"> <p class="title_block"><a href="{$link->getPageLink('prices-drop')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></p> <div class="block_content"> {if $special} <ul class="products clearfix"> {foreach from=$special item='product' name='special'} {if $smarty.foreach.special.index < 4} <li class="product_image"> <a href="{$product.link}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small_default')}" alt="{$product.legend|escape:html:'UTF-8'}" height="{$smallSize.height}" width="{$smallSize.width}" title="{$product.name|escape:html:'UTF-8'}" /></a><br/> </li> <li> {if !$PS_CATALOG_MODE} {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"><span>-{$specific_prices.reduction*100|floatval}%</span></span> {/if} {/if} {/if} <p class="s_title_block"><a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}">{$product.name|escape:html:'UTF-8'}</a></p> {if !$PS_CATALOG_MODE} <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span> <span class="price">{if !$priceDisplay}{displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc}{/if}</span> {/if} {/if} {/foreach} </li> </ul> <p> <a href="{$link->getPageLink('prices-drop')}" class="link-all" title="{l s='All specials' mod='blockspecials'}">» {l s='All specials' mod='blockspecials'}</a> </p> {else} <p>{l s='No specials at this time' mod='blockspecials'}</p> {/if} </div> </div> <!-- /MODULE Block specials --> and for blockspecials.php <?php /* * 2007-2013 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-2013 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ 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 = '0.8'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Specials block'); $this->description = $this->l('Adds a block displaying current product specials.'); } public function install() { return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('header')); } public function getContent() { $output = '<h2>'.$this->displayName.'</h2>'; if (Tools::isSubmit('submitSpecials')) { Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)(Tools::getValue('always_display'))); $output .= '<div class="conf confirm">'.$this->l('Settings updated').'</div>'; } return $output.$this->displayForm(); } public function displayForm() { return ' <form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post"> <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend> <label>'.$this->l('Always display this block.').'</label> <div class="margin-form"> <input type="radio" name="always_display" id="display_on" value="1" '.(Tools::getValue('always_display', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) ? 'checked="checked" ' : '').'/> <label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label> <input type="radio" name="always_display" id="display_off" value="0" '.(!Tools::getValue('always_display', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) ? 'checked="checked" ' : '').'/> <label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label> <p class="clear">'.$this->l('Show the block even if no product is available.').'</p> </div> <center><input type="submit" name="submitSpecials" value="'.$this->l('Save').'" class="button" /></center> </fieldset> </form>'; } public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; 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), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($special =Product::getPricesDrop($this->context->language->id,0,10))) return; $this->smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } 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'); } } 2 Link to comment Share on other sites More sharing options...
jahidulewu Posted August 12, 2013 Share Posted August 12, 2013 In my homepage or feature products, specials or specials block is not working. In this link http://www.realamberjewelry.com/prices-drop it is working. I try both special and specials for this code. public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($specials =Product::getPricesDrop($this->context->language->id,0,10)) return; $this->smarty->assign(array( 'specials' => $specials, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 12, 2013 Author Share Posted August 12, 2013 Read this How to call and right column content to center column? Suppose I want to show new product from right to center colum then... I will go to its module folder and then will open its php file i.e. blocknewproducts.php here i can see public function hookRightColumn($params){ // functions code do not change this code } no need to change any code i will just copy and paste above code just below it. public function hookRightColumn($params){ // functions code do not change this code } Now i will change the name of pasted function as hookDisplayHome($params) So now the code will be public function hookDisplayHome($params){ // functions code do not change this code } Now I will go to admin panel and position and new product then transplant a module then i will select displayHome save. Link to comment Share on other sites More sharing options...
PascalVG Posted August 12, 2013 Share Posted August 12, 2013 Thanks for the files, Rajesh. Appreciated! pascal 1 Link to comment Share on other sites More sharing options...
jahidulewu Posted August 13, 2013 Share Posted August 13, 2013 Thanks Rajesh now its working, But now there is another problem It is showing 4 items now but all images are same all products are same...so it is use less. When I refresh page then it changes the products but again all 4 are same. can u or Nemo1 or any other explain with code. I am new in prestashop My site is: http://www.realamberjewelry.com/ thanks advance Link to comment Share on other sites More sharing options...
PascalVG Posted August 13, 2013 Share Posted August 13, 2013 Hi Jahi, Did you change the product selector to: (see red code) public function hookDisplayHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; if (!($specials =Product::getPricesDrop($this->context->language->id,0,10)) return; $this->smarty->assign(array( 'specials' => $specials, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'smallSize' => Image::getSize(ImageType::getFormatedName('small')), )); return $this->display(__FILE__, 'blockspecials.tpl'); } pascal Link to comment Share on other sites More sharing options...
jahidulewu Posted August 13, 2013 Share Posted August 13, 2013 if (!($specials =Product::getPricesDrop($this->context->language->id,0,10)) No I did not change it. Can you give me the exact code? Thanks for your reply. Jahid Link to comment Share on other sites More sharing options...
PascalVG Posted August 13, 2013 Share Posted August 13, 2013 Hi Jahid, Rajesh did so in post #22 above and his manual how to change it exactly in his post #24. Just follow what he tells there and you're good. Link to comment Share on other sites More sharing options...
Rajesh Kumar Yadav Posted August 16, 2013 Author Share Posted August 16, 2013 Hello Jahi, Just copy & paste my code. Regard Rajesh Link to comment Share on other sites More sharing options...
Céline13240 Posted September 10, 2013 Share Posted September 10, 2013 Hi, I actually works with prestashop 1.5.5.0. I use this solution when i change my version of prestashop from 1.5.3.1 to 1.5.5.0 because my changes doesn't works anymore. So, thank you for this code. Nevertheless, i have a problem. Now, i can see all my specials products but i want to display only 2 products. So my question is : How can i choose the number of products i want to display ? Thank you for your answers. Link to comment Share on other sites More sharing options...
Céline13240 Posted September 10, 2013 Share Posted September 10, 2013 Sorry, forget my question. I've made a syntax mistake. It's ok now. Thank you. Link to comment Share on other sites More sharing options...
Rokixz Posted October 9, 2013 Share Posted October 9, 2013 (edited) Hello everybody, glad there are some people who found solution to the problem. I also have one. I want to show more than one image in right sidebar. As Rajesh wrote 2 files that user must replace, I've tried to do that, but still only one item shows. The most interesting part is that I've tried to delete both blockspecial.tpl in module dir and in template dir - nothing happens, still same result (one product) is showing, so I'm not talking about changing those files because there are no effect after all. PHP file works without problem. I'm using standard default Prestashop 1.5 template, but seems to be difficult to call out this function. Anyway, hope somebody could help me, it's a bit bothering when you should take all day to search for a solution. Thank you for your help in advance! P.S. Seems it was cache, but after all, I do get absolutely unneeded items, when I click on link „see more“, I see proper products, check in http://namuakcentai.lt/ Thanks for reply. Edited October 9, 2013 by Rokixz (see edit history) Link to comment Share on other sites More sharing options...
casstete Posted December 1, 2013 Share Posted December 1, 2013 I tried the code of Rajesh in 1.5.6.1 and it didn't change anything . Any more suggestions ? Link to comment Share on other sites More sharing options...
vekia Posted December 1, 2013 Share Posted December 1, 2013 I tried the code of Rajesh in 1.5.6.1 and it didn't change anything . Any more suggestions ? you mean code in #24 post? Link to comment Share on other sites More sharing options...
casstete Posted December 2, 2013 Share Posted December 2, 2013 you mean code in #24 post? No the #22 , I just copy pasted it ( using default theme with default position ) but it didn't change anything ( keep clearing cache to be sure ) I edited both tmp & php , I'm not familiar with coding but I though this should have been possible with #22 Regardsing #24 I believe it's for repositioning / horizintal displaying , I just default position much appreciated john Link to comment Share on other sites More sharing options...
vekia Posted December 3, 2013 Share Posted December 3, 2013 ok, so what .tpl file you changed? sometimes theme directory has got this module file - if so - it's necessary to change code there Link to comment Share on other sites More sharing options...
Rasq Posted December 4, 2013 Share Posted December 4, 2013 (edited) Hi I got this module http://www.prestashop.com/forums/topic/87549-solved-module-specials-product-at-center-column-homefeatured-modification/ and i modified a little in tpl file Is ok if i put a link here with what i made it? Edited December 4, 2013 by Rasq (see edit history) Link to comment Share on other sites More sharing options...
casstete Posted December 5, 2013 Share Posted December 5, 2013 ok, so what .tpl file you changed? sometimes theme directory has got this module file - if so - it's necessary to change code there I changed the blockspecial.tmp ... rather replaced it as above . So I use the default theme and replace th blockspecial.tmp and php as suggested above . I spent some time and when i did "other" codes a.p. some other forums and one non forum I can see changes ( it doen't work either but I see changes ) So I can't believe it's cache as the others reacted immediately to changes . Maybe "Rasq" has a solution with his code ? thanks Link to comment Share on other sites More sharing options...
Rasq Posted December 5, 2013 Share Posted December 5, 2013 (edited) Here is the download link for what changes i made in it SpecialsCenterdec2013.zip I hope i put the link in according with forum's terms Edited December 5, 2013 by Rasq (see edit history) Link to comment Share on other sites More sharing options...
haroldveeckmans Posted January 6, 2014 Share Posted January 6, 2014 This is by far the best working explanations I found about this topic (incl. files) http://nemops.com/product-list-prestashop-specials-module/ enjoy ! Link to comment Share on other sites More sharing options...
marcellolaforgia Posted May 28, 2014 Share Posted May 28, 2014 Dear friends, I would like to ask you a hand. I installed the module you speak of prestashop 1.6, but can having product specials, none appears. Could you explain why? Link to comment Share on other sites More sharing options...
vekia Posted May 28, 2014 Share Posted May 28, 2014 Dear friends, I would like to ask you a hand. I installed the module you speak of prestashop 1.6, but can having product specials, none appears. Could you explain why? the most important questions: you've got products with dropped prices? Link to comment Share on other sites More sharing options...
marcellolaforgia Posted May 29, 2014 Share Posted May 29, 2014 Dear Vekia, I put the "special" products, they are. In practice, in the bottom of the home nothing appears, despite, checking the Live Edit, the module is present. This problem may be caused by the fact that I'm using version 1.6 of prestashop? Or something else? How can I fix this? Link to comment Share on other sites More sharing options...
G.E.S. Posted June 19, 2014 Share Posted June 19, 2014 Hi, "more-than-1-special-products-in-prestashop" You have the solution for version 1.6 of presta? Thanks! Link to comment Share on other sites More sharing options...
bullet_tooth Posted September 25, 2014 Share Posted September 25, 2014 Up! Link to comment Share on other sites More sharing options...
sworld Posted August 5, 2015 Share Posted August 5, 2015 Hi, "more-than-1-special-products-in-prestashop" You have the solution for version 1.6 of presta? Thanks! Link to comment Share on other sites More sharing options...
NemoPS Posted August 6, 2015 Share Posted August 6, 2015 Use Product::getPricesDrop with the appropriate settings Link to comment Share on other sites More sharing options...
Recommended Posts