skywhi Posted October 11, 2013 Share Posted October 11, 2013 Hello everybody! I search since hours to put the reference of the product in block "bestsellers". I tried to write "product.reference" under "product.price" but it did'nt works. I need help 'cause i'm lost! Thank you! Link to comment Share on other sites More sharing options...
jgullstr Posted October 11, 2013 Share Posted October 11, 2013 Hello, Unfortunately, the product reference is not exposed by the function determining the bestsellers. You need to alter the query (preferrably in an override) in the ProductSale::getBestSalesLight() method to include the field p.reference. Link to comment Share on other sites More sharing options...
skywhi Posted October 11, 2013 Author Share Posted October 11, 2013 Ok, but please could you explain to me where i do the modification and what modification exactly, 'cause i never used override before. Thank you very much! Link to comment Share on other sites More sharing options...
jgullstr Posted October 11, 2013 Share Posted October 11, 2013 Ok, but please could you explain to me where i do the modification and what modification exactly, 'cause i never used override before. Thank you very much! Try add the attached file to your override\classes folder, then delete the file cache/class_index.php, and see if it works. (PS 1.5.5) ProductSale.php Link to comment Share on other sites More sharing options...
skywhi Posted October 11, 2013 Author Share Posted October 11, 2013 In override/classes and next in what folder? I've "webservice", "tax", "stock", "shop", "range", "pdf", "order", "module", "log", "helper", "exception", "db", "controller" and "cache". Sorry if the question is stupid but i'm not developer. Thanks Link to comment Share on other sites More sharing options...
skywhi Posted October 12, 2013 Author Share Posted October 12, 2013 It works! But i want also put if the product is a sale, a reduction or a new product with this code in the bestsellers.tpl: {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span> {elseif isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="on_sale">{l s='On sale!'}</span> {elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="discount">{l s='Promotion'}</span> {else}<span class="actu">{l s='Actuality'}</span> {/if} Could-you help me a second time and after that, I'll leave you alone, I promise! Link to comment Share on other sites More sharing options...
skywhi Posted October 13, 2013 Author Share Posted October 13, 2013 I need some help with that. I know that i must alter the query in ProductSale to include fiels p.new, p.reduction and p.on_sale but where and how? Thanks to try to help me. Link to comment Share on other sites More sharing options...
skywhi Posted October 15, 2013 Author Share Posted October 15, 2013 Does anyone have an idea for help me? Link to comment Share on other sites More sharing options...
skywhi Posted October 17, 2013 Author Share Posted October 17, 2013 I'm still searching solution for my problem. If somebody has an idea, that's great! Link to comment Share on other sites More sharing options...
jgullstr Posted October 21, 2013 Share Posted October 21, 2013 Hello, sorry for late reply. Try the attached file. Turn off (or clear) cache before testing (Backoffice > Advanced Parameters > Performance) ProductSale.php Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 I'm still searching solution for my problem. If somebody has an idea, that's great! jest add p.reference, to: $sql = 'SELECT p.reference, p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, MAX(image_shop.`id_image`) id_image, il.`legend`, Link to comment Share on other sites More sharing options...
reinoplantae Posted October 7, 2016 Share Posted October 7, 2016 Hi, anyone can help me on how to do it on PS 1.6.0.9??? Tried the above methods with no success. I need to show the product reference both in New Products and Best Sellers blocks in home. Thanks Link to comment Share on other sites More sharing options...
rocky Posted October 8, 2016 Share Posted October 8, 2016 You'll need to override the ProductSale::getBestSalesLight() and Product::getNewProducts() functions and add p.`reference` to the SELECT statements. You can then use the following in the modules' TPL files: {$product.reference} Link to comment Share on other sites More sharing options...
reinoplantae Posted October 11, 2016 Share Posted October 11, 2016 Hi rocky, thanks!!! where do I find these two variables you said, in what file??? ( ProductSale::getBestSalesLight() and Product::getNewProducts()). My ProductSale.php file doesn't contain it. Link to comment Share on other sites More sharing options...
rocky Posted October 11, 2016 Share Posted October 11, 2016 It's line 175 (in PrestaShop v1.6.1.7) of classes/ProductSale.php: p.id_product, IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute, pl.`link_rewrite`, pl.`name`, pl.`description_short`, product_shop.`id_category_default`, And line 2307 (in PrestaShop v1.6.1.7) of classes/Product.php: 'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, Though I now realise that it already has p.*, so the reference should already be there in the new products. It's just the best sellers you need to add p.reference, Link to comment Share on other sites More sharing options...
reinoplantae Posted October 11, 2016 Share Posted October 11, 2016 rocky, you're the guy!!!! thanks a lot, it's working now! i was just changing the wrong tpl file, since my bestsellers and newproducts blocks aren't from default theme but an external module. Link to comment Share on other sites More sharing options...
rocky Posted October 11, 2016 Share Posted October 11, 2016 I'm happy you solved your problem. 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