Jump to content

Show product combination location in frontoffice


Recommended Posts

Hi ! I'm trying to use the location field in template, to enter some information at the combination level to show to customers (when they select a certain combination). The data is correctly inserted into the 'ps_product_attribute' table as seen in the screenshot attached.

Is it possible to get the data out from the "location" field to show it in product_variants.tpl template ?



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.`location`
	FROM `' . _DB_PREFIX_ . 'product_attribute` pa
	WHERE id_product_attribute = ' . $this->getIdProductAttributeByGroupOrRequestOrDefault();
$product['product_attribute_location'] = '';
if ($results = Db::getInstance()->executeS($query)) {
	foreach ($results as $row) {
		$product['product_attribute_location'] = $row['location'];

Then use  {$product['product_attribute_location']} 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...