arash_a2k Posted September 24, 2013 Share Posted September 24, 2013 (edited) Hello. Can someone help me plz. I want to group products by manufacturer in each category or sub-category page instead of showing all products followed by each other(default behavior). for example in laptop page we have four groups: Sony, Apple, Samsung, Dell : and under each of them are their laptops. Also I want to list products by category in manufacturer page. For example in Apple page we can have several groups containing apple products: Ipods, Mac books, Iphones..... It would be fantastic If someone could give me the right code. Even introducing modules that can do these for me is appreciated. I use prestashop 1.5.4.1 Thanks Edited September 24, 2013 by arash_a2k (see edit history) Link to comment Share on other sites More sharing options...
arash_a2k Posted September 25, 2013 Author Share Posted September 25, 2013 Hi. I managed to solve my first problem ( grouping by manufacturer ) . Thanks to this post : http://www.prestashop.com/forums/topic/223689-solved-list-manufacturers-under-category-page-ps15/ What I had to done was changing the code in the CategoryController.php to this : at the end of the funtion "public function assignProductList()" you need to modify it to the following: $this->manufacturers = array(); if ($this->cat_products) foreach ($this->cat_products as &$product) { $this->manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), $this->context->language->id); } $this->context->smarty->assign(array( 'nb_products', $this->nbProducts, 'manufacturers' => $this->manufacturers, )); then add these lines of code to your product-list.tpl and modify the css to achieve what you want. {if $page_name == 'category'} <!-- Products list --> {foreach from=$manufacturers item=manufacturer} <p><strong>{$manufacturer->name|escape:'htmlall':'UTF-8'}</strong></p> <ul id="product_list" class="clear"> {foreach from=$products item=product name=products} {if isset($product.manufacturer_name)} {if $manufacturer->name == $product.manufacturer_name} ..... {/if} {/foreach} </ul> {/foreach} <!-- /Products list --> {else} <!-- Products list --> default product-list.tpl code ..... <!-- Products list --> {/if} but my second issue is still unsolved If I can solve that I will inform here Link to comment Share on other sites More sharing options...
faDdy Posted December 15, 2013 Share Posted December 15, 2013 Is there a way to do this on Prestashop 1.4.8.2 ? Thank you. Link to comment Share on other sites More sharing options...
craftyhand Posted August 4, 2014 Share Posted August 4, 2014 Hi. I managed to solve my first problem ( grouping by manufacturer ) . Thanks to this post : http://www.prestashop.com/forums/topic/223689-solved-list-manufacturers-under-category-page-ps15/ What I had to done was changing the code in the CategoryController.php to this : at the end of the funtion "public function assignProductList()" you need to modify it to the following: $this->manufacturers = array(); if ($this->cat_products) foreach ($this->cat_products as &$product) { $this->manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), $this->context->language->id); } $this->context->smarty->assign(array( 'nb_products', $this->nbProducts, 'manufacturers' => $this->manufacturers, )); then add these lines of code to your product-list.tpl and modify the css to achieve what you want. {if $page_name == 'category'} <!-- Products list --> {foreach from=$manufacturers item=manufacturer} <p><strong>{$manufacturer->name|escape:'htmlall':'UTF-8'}</strong></p> <ul id="product_list" class="clear"> {foreach from=$products item=product name=products} {if isset($product.manufacturer_name)} {if $manufacturer->name == $product.manufacturer_name} ..... {/if} {/foreach} </ul> {/foreach} <!-- /Products list --> {else} <!-- Products list --> default product-list.tpl code ..... <!-- Products list --> {/if} but my second issue is still unsolved If I can solve that I will inform here Hi. I managed to solve my first problem ( grouping by manufacturer ) . Thanks to this post : http://www.prestashop.com/forums/topic/223689-solved-list-manufacturers-under-category-page-ps15/ What I had to done was changing the code in the CategoryController.php to this : at the end of the funtion "public function assignProductList()" you need to modify it to the following: $this->manufacturers = array(); if ($this->cat_products) foreach ($this->cat_products as &$product) { $this->manufacturers[$product['id_manufacturer']] = new Manufacturer(intval($product['id_manufacturer']), $this->context->language->id); } $this->context->smarty->assign(array( 'nb_products', $this->nbProducts, 'manufacturers' => $this->manufacturers, )); then add these lines of code to your product-list.tpl and modify the css to achieve what you want. {if $page_name == 'category'} <!-- Products list --> {foreach from=$manufacturers item=manufacturer} <p><strong>{$manufacturer->name|escape:'htmlall':'UTF-8'}</strong></p> <ul id="product_list" class="clear"> {foreach from=$products item=product name=products} {if isset($product.manufacturer_name)} {if $manufacturer->name == $product.manufacturer_name} ..... {/if} {/foreach} </ul> {/foreach} <!-- /Products list --> {else} <!-- Products list --> default product-list.tpl code ..... <!-- Products list --> {/if} but my second issue is still unsolved If I can solve that I will inform here Hi arash_a2k, Were you able to find solution to second issue? Also I want to list products by category in manufacturer page. For example in Apple page we can have several groups containing apple products: Ipods, Mac books, Iphones..... I am trying to implement same feature in my website too. I will be really thankful if you have solved the problem and share your expertise on this issue. Link to comment Share on other sites More sharing options...
benzenewings Posted June 8, 2015 Share Posted June 8, 2015 Hi Arash, I am having troubles with your code. Can you give more detail what needs to be in the "......" areas perhaps? I am on 1.6 and getting unclosed IF errors. . thanks for sharing your input. much appreciated. 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