Jump to content

Put product reference in block bestsellers


skywhi

Recommended Posts

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

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

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

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

  • 2 years later...

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...