NemoPS Posted March 11, 2013 Share Posted March 11, 2013 Hey everybody! I just finished writing a short tutorial on how to aklways display the lowest possible price in product list. This means that you will be able to display from 12$ for example, if one of you products costs 12$ when bought in stock; even in the original price is different. Really useful for wholesales and office suppliers Here: http://nemops.com/lowest-price-prestashop-product-list/ Cheers! Fabio Link to comment Share on other sites More sharing options...
sshare Posted November 22, 2013 Share Posted November 22, 2013 Hi Fabio,Thanks for the tutorial you posted, could you please confirm if it will work with 1.5.0.17? As when I add the coding the category list page goes completely blank, so not sure what I'm doing wrong there. Link to comment Share on other sites More sharing options...
NemoPS Posted November 22, 2013 Author Share Posted November 22, 2013 Hi! I have not tested it on that version, but it *should* work Link to comment Share on other sites More sharing options...
pixelwebmx Posted February 11, 2014 Share Posted February 11, 2014 Is not working in 1.5.6 Link to comment Share on other sites More sharing options...
NemoPS Posted February 11, 2014 Author Share Posted February 11, 2014 It works for me check that you copied everything correctly, do you get any error? Link to comment Share on other sites More sharing options...
ricky11 Posted March 14, 2014 Share Posted March 14, 2014 (edited) Isn't this from this blog? http://blog.arvixe.com/display-the-lowest-price-in-prestashops-product-list/ Edit : Ahh same author okay. i am going to try this.. why does it display by the highest combination price? Edited March 14, 2014 by ricky11 (see edit history) Link to comment Share on other sites More sharing options...
generalexperts Posted March 17, 2014 Share Posted March 17, 2014 Is there a way to show "From $xx" just for products that have multiple combinations. My site has a few product items that have multiple sizes. The sizes greatly vary in price. Currently, the product list shows it as the lowest price, but it doesn't say "From" so it could be very misleading for people. I would only need it to say "From" only in this circumstance. Not needed for every product listing. Thanks! Link to comment Share on other sites More sharing options...
YoChappu Posted April 1, 2014 Share Posted April 1, 2014 (edited) Thanks! But there is a problem with taxes. You never change price_tax_ecl. value. So, if you need to display it in your template, the value is false. And actually, I display prices with tax in my shop, and the lowest price calculate is without tax. Edited April 1, 2014 by YoChappu (see edit history) Link to comment Share on other sites More sharing options...
Shad86 Posted June 3, 2014 Share Posted June 3, 2014 Works for me on Prestashop 1.5.5.0 But I have a reseller group too and they still becomes the single price. Only the normal customers get the lowest price in the product list. Link to comment Share on other sites More sharing options...
NemoPS Posted June 4, 2014 Author Share Posted June 4, 2014 Works on 1.6.0.6, tested yesterday No idea about the reseller, try fiddling with the part concerning customer groups! Link to comment Share on other sites More sharing options...
Shad86 Posted June 4, 2014 Share Posted June 4, 2014 Yes, I have two customer groups. "Customer" and "Reseller". The customer get the prices with tax and everything is fine with the lowest price. But the reseller get the prices without tax and he see the single prices, not the lowest prices. Link to comment Share on other sites More sharing options...
NemoPS Posted June 4, 2014 Author Share Posted June 4, 2014 It might be enough to check out the priceDisplay part in the template then Link to comment Share on other sites More sharing options...
Shad86 Posted June 4, 2014 Share Posted June 4, 2014 I´ve looked for it but I can´t find where the shop made the difference between tax and without tax... Link to comment Share on other sites More sharing options...
NemoPS Posted June 5, 2014 Author Share Posted June 5, 2014 hm... are discounts setup so that they apply to all customer groups? Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 (edited) Good morning, yes they apply to all customer groups, all customer, all countries. Just currency is used on "Euro" but there is only euro in the shop at the moment. If I change the reseller group tp "with tax", everything is fine. Only if I change it to "without tax" the minimum prices can´t get shown. Edited June 6, 2014 by Shad86 (see edit history) Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 (edited) In product_list.tpl, there is a part: {if !$priceDisplay} {convertPrice price=$product.price} {else} {convertPrice price=$product.price_tax_exc} {/if} Is it possible that your tutorial only takes a change on ".price"? Do I have to do the whole tutorial again but with ".price_tax_exc" instead of ".price"? Only ad the last line again like this doesn´t run. It get negative prices than. $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['price_tax_exc'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; Edited June 6, 2014 by Shad86 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted June 6, 2014 Author Share Posted June 6, 2014 Weird, I'm clueless. Try var_dump(min($prices_array)); from the controller, right before assigning it, see what it says Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 (edited) On the shop top it says: float(3.61) float(19.54) string(9) "-1.000000" float(50.96) float(-7.57) float(34.03) Don´t know what it means. Edit: These are the prices of the products in this category... Did I put it in the right place? I can put some screenshot on my post if you want, I calculate the whole time but I can´t get the price it shows if I put in the line: $this->cat_products[$key]['price_tax_exc'] = min($prices_array); It does something but I don´t know what. Without tax, the price is 46,81€. The lowest quantity price is 10,51€. But it shows 3,61€ in the product list... I try to understand what it does to maybe fix it. Edited June 6, 2014 by Shad86 (see edit history) Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 I understand now... It simply take the price without tax minus the lowest discount price. BUT this can make negative prices. I have to put in new prices especially for the reseller group. That runs. It´s a pity that the lowest discount price calculation doen´t run for them too... Link to comment Share on other sites More sharing options...
NemoPS Posted June 6, 2014 Author Share Posted June 6, 2014 Can you paste here the bit of code where you added the var_dump? Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 (edited) Sure: if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) $price = $discount['price']; else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $this->cat_products[$key]['price'] = min($prices_array); var_dump(min($prices_array)); $this->cat_products[$key]['price_tax_exc'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; Edited June 6, 2014 by Shad86 (see edit history) Link to comment Share on other sites More sharing options...
Shad86 Posted June 6, 2014 Share Posted June 6, 2014 (edited) If the price get calculated minus the discount prices without tax (that are shown in the product), everything would be ok. But it uses the discount prices with tax, so it can calculate negative prices... I can´t enough PHP but isn´t it possible to add an "if than else" command? Something like: if (['price_tax_exc']) $price = $discount['price_tax_exc']; else { $price = $product['price_without_reduction'] - $discount['price_tax_exc']; } or something like this? I mean that it calculate with the discounts without tax, not the discounts with tax. The table in the product calculate the discounts with and without tax like it should. So I think it must be possible on one way. Edited June 6, 2014 by Shad86 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted June 7, 2014 Author Share Posted June 7, 2014 Yeah you can try that, price tax excluded would actually be priceDisplay in the frontend, you can get it this way Group::getPriceDisplayMethod(Group::getCurrent()->id); Link to comment Share on other sites More sharing options...
Shad86 Posted June 10, 2014 Share Posted June 10, 2014 Dear Nemo1, and where do I have to put it in? Before the: $this->cat_products[$key]['price_tax_exc'] = min($prices_array); ?? Link to comment Share on other sites More sharing options...
NemoPS Posted June 10, 2014 Author Share Posted June 10, 2014 yeah, the basing on that you assign the tax or taxless price Link to comment Share on other sites More sharing options...
Jacek Es Posted August 23, 2014 Share Posted August 23, 2014 Very useful tutorial. It works on 1.6.0.8. If we show the lowest price from on product list page it would also be good to show it on product comparison. I can't make it to work though. Am I right in thinking that it should be done by adding CompareController.php to overrides with the code provided and modify products-comparison.tpl? Please help... Link to comment Share on other sites More sharing options...
NemoPS Posted August 25, 2014 Author Share Posted August 25, 2014 Yes, you are right, that should be the way. Check if the override is working in the first place, like by adding die('test'); in the method you override. Just to see if it's working Link to comment Share on other sites More sharing options...
houin Posted August 25, 2014 Share Posted August 25, 2014 Yes, you are right, that should be the way. Check if the override is working in the first place, like by adding die('test'); in the method you override. Just to see if it's working Hello and thank you for this tuto I am on 1.6.06 and doc if I understand well it is necessary to replace: {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)} <span itemprop="price" class="price product-price"> {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} </span> By this code: {If isset ($ product.show_price) && $ product.show_price && isset ($ restricted_country_mode)!} < durée classe = "prix" de style = "display: inline;" > {ls = 'From'} {if $ priceDisplay! } {convertPrice prix = $ product.price} {autre} {convertPrice prix = $ product.price_tax_exc} {/ if} </ durée > < br /> {/ if} Is it?. Thank you Link to comment Share on other sites More sharing options...
NemoPS Posted August 26, 2014 Author Share Posted August 26, 2014 uh? no, that second snippet you pasted is all wrong, this is the one {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{l s='From'} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if} Link to comment Share on other sites More sharing options...
Jacek Es Posted August 26, 2014 Share Posted August 26, 2014 Nemo1. Yes. The override file is working but I believe the content of it needs to be altered in order to work for product comparison, for example the last line of your code to "reassign the product list with our corrected prices": $this->context->smarty->assign('products', $this->cat_products); I am not good at coding and don't know what needs to be changed here. Also, in the code that you provided for override file there are more fragments that refer to "cat_products". Not sure if this would work for CompareController.php Link to comment Share on other sites More sharing options...
NemoPS Posted August 27, 2014 Author Share Posted August 27, 2014 Ah, well yes, of course you need to change variable names, it should be $listProducts there Link to comment Share on other sites More sharing options...
Jacek Es Posted September 2, 2014 Share Posted September 2, 2014 It looks that there is more going on within function initContent() in CompareController.php than in CategoryController.php. I tried to add the code to CompareController.php but it didn't work for me. Where exactly would you add the code? Has anyone achieved displaying 'price from' on product comparison? I would appreciate help with this... Link to comment Share on other sites More sharing options...
Szed Posted February 21, 2015 Share Posted February 21, 2015 Dear Nemo1, and where do I have to put it in? Before the: $this->cat_products[$key]['price_tax_exc'] = min($prices_array); ?? Hello Shad86, same question here! I gave to display minimum price from classic User Group who have display tax ON (that is okay), and for Pro Group who have display tax OFF. Have you reach that ? Thanks! Link to comment Share on other sites More sharing options...
Shad86 Posted February 23, 2015 Share Posted February 23, 2015 Its a long time ago... We have an issue with don´t displaying the tax. I think it was because of our "from" price. It shows minus prices than because the price without tax minus prices with tax. So we decided to show tax everytime and it´s ok for us. Link to comment Share on other sites More sharing options...
[email protected] Posted January 19, 2016 Share Posted January 19, 2016 don't work in 1.6.0.9 Link to comment Share on other sites More sharing options...
NemoPS Posted January 20, 2016 Author Share Posted January 20, 2016 actually, it does for me, double check what you did Link to comment Share on other sites More sharing options...
Jacek Es Posted January 20, 2016 Share Posted January 20, 2016 It also works on 1.6.0.8. Happy with this fix ;-) Link to comment Share on other sites More sharing options...
Dagostino Posted January 25, 2016 Share Posted January 25, 2016 hello, seem to dont work on 1.6.1. I did all, this is my CategoryController.php override. The price displaying is the "for 1 unit", not the lowest If you can help me ? thank's ! CategoryController.php Link to comment Share on other sites More sharing options...
NemoPS Posted January 27, 2016 Author Share Posted January 27, 2016 Are you using the layered navigation? That would prevent this from working properly Link to comment Share on other sites More sharing options...
Dagostino Posted January 27, 2016 Share Posted January 27, 2016 Thank's for your answer ! No i'm not...i cant find a solution, only a module at 80$ but i dont even know if it ll work... i send you a mp just with link of website. Link to comment Share on other sites More sharing options...
NemoPS Posted January 29, 2016 Author Share Posted January 29, 2016 It's hard to tell what's going on, it can be anything on the php side. THe only thing I can say is check the code your wrote, and make sure the override is actually running. Dump some variables and see where it's failing Link to comment Share on other sites More sharing options...
Dagostino Posted January 29, 2016 Share Posted January 29, 2016 Thank's for your answer, unfortunatelly im not a dev, so i cant do this ^^ i ll must buy the 80€ module.. Link to comment Share on other sites More sharing options...
samverdyck Posted April 28, 2016 Share Posted April 28, 2016 Thank's for your answer, unfortunatelly im not a dev, so i cant do this ^^ i ll must buy the 80€ module.. Dagostino, did you manage to make it work with the module? Which module is it? Thanks! Link to comment Share on other sites More sharing options...
Dagostino Posted April 28, 2016 Share Posted April 28, 2016 No i didnt, i bough the module for it. The module name is Agile quantity discount indicator. It work on my presta 1.6.1.4 but well, it's a pay module. Link to comment Share on other sites More sharing options...
samverdyck Posted April 28, 2016 Share Posted April 28, 2016 No i didnt, i bough the module for it. The module name is Agile quantity discount indicator. It work on my presta 1.6.1.4 but well, it's a pay module. Thanks for your answer, I will look into because can't get the tutorial get to work either. Link to comment Share on other sites More sharing options...
Ugo Fontana Posted June 27, 2016 Share Posted June 27, 2016 (edited) Hi everyone!! It worked perfectly for me with 1.6.1 but i have a little problem> i'd like to show same discounted price also in "new products" "homefeatured" CAN I? http://www.magliettepersonalizzate.info(home not working) http://www.magliettepersonalizzate.info/index.php?id_category=13&controller=category(working good) Edited June 27, 2016 by Ugo Fontana (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted June 29, 2016 Author Share Posted June 29, 2016 You can basically apply the same procedure to them, but you might have to remove caching from these modules before, otherwise you won't see you changes take place Link to comment Share on other sites More sharing options...
Ugo Fontana Posted July 4, 2016 Share Posted July 4, 2016 You can basically apply the same procedure to them, but you might have to remove caching from these modules before, otherwise you won't see you changes take place Ciao NEMO it's not totally clear what you mean ( cause i'm not expert in php ) i should modify other .tpl ? (for example in modules interested -newproducts, homefeatured-) i should add more override controllers? and about removing caching from these modules before i can't understand what i have to do ( sorry cause i'm a nub hope you have patience to explain me step by step pm me (also italian) if you think we go offtopic here sorry for disturbing again Link to comment Share on other sites More sharing options...
Florian Lemaitre Posted July 13, 2016 Share Posted July 13, 2016 (edited) On Prestashop 1.6.5 you can use "hookActionProductListModifier" in your module. This way, it's also working with Blocklayered module. public function hookActionProductListModifier($params) { if (isset($params['cat_products']) && ! empty($params['cat_products'])) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($params['cat_products'] as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) { $price = $discount['price']; } else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $params['cat_products'][$key]['price_tax_exc'] = min($prices_array); $params['cat_products'][$key]['qt_disc'] = true; } } } } Edited July 13, 2016 by Mangateur (see edit history) Link to comment Share on other sites More sharing options...
Ugo Fontana Posted July 13, 2016 Share Posted July 13, 2016 (edited) On Prestashop 1.6.5 you can use "hookActionProductListModifier" in your module. This way, it's also working with Blocklayered module. public function hookActionProductListModifier($params) { if (isset($params['cat_products']) && ! empty($params['cat_products'])) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($params['cat_products'] as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) { $price = $discount['price']; } else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $params['cat_products'][$key]['price_tax_exc'] = min($prices_array); $params['cat_products'][$key]['qt_disc'] = true; } } } } wich module? where i should add the code you paste? sorry cause i'm really newbie i'm learning step by step while making my website http://www.magliettepersonalizzate.info Edited July 13, 2016 by Ugo Fontana (see edit history) Link to comment Share on other sites More sharing options...
luca82 Posted April 10, 2017 Share Posted April 10, 2017 For the version 1.7 someone have implemented this function? Link to comment Share on other sites More sharing options...
Shad86 Posted April 10, 2017 Share Posted April 10, 2017 Waiting for it too. Or a modul which gives me a placeholder. Something where you can type in the cheapest price by hand and it will be shown where the ground price normaly is, in the product list... Link to comment Share on other sites More sharing options...
chattago2002 Posted February 15, 2018 Share Posted February 15, 2018 Has anyone solved this issue? I would show the lowest price of a product from the different combination list prices. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now