Jump to content

Show product supplier reference combination in FO


robb84

Recommended Posts

Hi. I'm trying to show in product page the supplier reference according to combination selected  (like the default reference sku does).

I assigned the supplier and the supplier reference in BO for each combination attribute (in product option TAB).

With code: 

{$product.supplier_reference}

in product.tpl and product-variants.tpl, nothing show up . Any clue for this ?

Thanks

Ps: 1.7.2

Link to comment
Share on other sites

  • 3 weeks later...

You should modify /controllers/front/ProductController.php and in line ~1073 (method getTemplateVarProduct()) add:

$query = 'SELECT pa.`supplier_reference`
	FROM `' . _DB_PREFIX_ . 'product_attribute` pa
	WHERE id_product_attribute = ' . $this->getIdProductAttributeByGroupOrRequestOrDefault();
$product['product_attribute_supplier_reference'] = '';
if ($results = Db::getInstance()->executeS($query)) {
	foreach ($results as $row) {
		$product['product_attribute_supplier_reference'] = $row['supplier_reference'];
	}
}

Then use {$product['product_attribute_supplier_reference']} variable on template you want. For example /themes/your_theme/templates/catalog/_partials/product_details.tpl

 

If it works, then I would move those changes to override folder to prevent from being lost after prestashop core upgrade.

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...