mipapage Posted May 29, 2014 Share Posted May 29, 2014 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() { parent::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 More sharing options...
mipapage Posted May 29, 2014 Author Share Posted May 29, 2014 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))); else $attributes_combinations = array(); $this->context->smarty->assign('attributesCombinations', $attributes_combinations); } Adapting that got the job done. Link to comment Share on other sites More sharing options...
PascalVG Posted June 2, 2014 Share Posted June 2, 2014 Hi Mipa, Thanks for adding the found solution! I'll mark the topic as solved then, Happy selling, pascal Link to comment Share on other sites More sharing options...
mipapage Posted June 2, 2014 Author Share Posted June 2, 2014 Thanks Pascal, I had clicked the 'Mark as solved' button but couldn't get the title of the post to reflect that! Link to comment Share on other sites More sharing options...
PascalVG Posted June 2, 2014 Share Posted June 2, 2014 Hi Mipa, Indeed pressing solved doesn't change the title. That's a manual action. Please see my footer on how to do this. Pascal Link to comment Share on other sites More sharing options...
mipapage Posted June 2, 2014 Author Share Posted June 2, 2014 Thanks Pascal, I missed that 'use full editor' bit. Link to comment Share on other sites More sharing options...
reinoplantae Posted February 27, 2015 Share Posted February 27, 2015 Hello mipapage. Can you tell how did you "adapt" the code?? I can't figure out ... thanks! Link to comment Share on other sites More sharing options...
vijju Posted June 20, 2015 Share Posted June 20, 2015 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. Thanks Link to comment Share on other sites More sharing options...
jordibabot Posted July 3, 2019 Share Posted July 3, 2019 I would like to see this adaptation as well please. Thanks 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