Jump to content

[SOLVED] Products -> Combinations attributes on product-list.tpl


Recommended Posts

Hi there,


In the back end for products we have some attributes set in the tab 'Combinations' (see attached image). 

When I {debug} the product-list.tpl that data does not show up, however we would like to have access to that data to display along with the price on product-list.tpl, as these are the quantities 'per pack'.


Currently our theme shows the price, but it doesn't show that there are 100 units in the pack. My plan was to get this attribute and to show it along with the price.


I'm already hacking away in the category controller in order to add some more smarty variables, is there a decent way that I can get these attributes as well?

class CategoryController extends CategoryControllerCore

public function initContent()
	if($this->cat_products) {
		foreach ($this->cat_products as $key => $product) {
		 // *** I want to get the attributes here ***

	$this->context->smarty->assign('products', $this->cat_products);




Link to comment
Share on other sites

Happy days, you dig enough and you find it. I used the code from the ProductController.php

	 * Get and assign attributes combinations informations
	protected function assignAttributesCombinations()
		$attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id);
		if (is_array($attributes_combinations) && count($attributes_combinations))
			foreach ($attributes_combinations as &$ac)
				foreach ($ac as &$val)
					$val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val)));
			$attributes_combinations = array();
		$this->context->smarty->assign('attributesCombinations', $attributes_combinations);

Adapting that got the job done.

Link to comment
Share on other sites

  • 8 months later...
  • 3 months later...

Hi all

I'm new on prestashop and, i want to show my product combination price as on attributes selection in product-list.tpl, please give me right solution for it because i'm trying from a lots of day for this.


Link to comment
Share on other sites

  • 4 years later...

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