monish Posted November 23, 2013 Share Posted November 23, 2013 I need to display products under the heading of their category. How should I do that? I mean: display products grouped by category. Link to comment Share on other sites More sharing options...
vekia Posted November 24, 2013 Share Posted November 24, 2013 by default prestashop displays products from selected category... so i don't understand your problem well, can you shed some more light on your question please? Link to comment Share on other sites More sharing options...
monish Posted November 25, 2013 Author Share Posted November 25, 2013 I have sub categories and I need to display the sub categories on category page with sub category heading. I can see all the products but I want to display them grouped by sub category under the sub category heading. Link to comment Share on other sites More sharing options...
monish Posted November 25, 2013 Author Share Posted November 25, 2013 I have modified product-list.tpl and added the below code: {foreach from=$subcategories item=subcategory} <h2> {strip} {$subcategory.name|escape:'htmlall':'UTF-8'} {/strip} </h2> {/foreach} I am able to get the subcategory heading with this. Now I need to display the products associated to each subcategory under the subcategory heading. Please guide me. Thanks in advance/ Link to comment Share on other sites More sharing options...
vekia Posted November 25, 2013 Share Posted November 25, 2013 in this case you have to add variable with products from each subcategory to the smarty array, there is no other way unfortunately. (CategoryController.php) Link to comment Share on other sites More sharing options...
monish Posted November 25, 2013 Author Share Posted November 25, 2013 I am new to PestraShop. Can you please guide me how I can do that. Can I do it using CategoryController.php? Link to comment Share on other sites More sharing options...
vekia Posted November 25, 2013 Share Posted November 25, 2013 it will not be as easy as it seems. there is a function: protected function assignSubcategories() { if ($subCategories = $this->category->getSubCategories($this->context->language->id)) { $this->context->smarty->assign(array( 'subcategories' => $subCategories, 'subcategories_nb_total' => count($subCategories), 'subcategories_nb_half' => ceil(count($subCategories) / 2) )); } } you have to assign productList for each subcategory that you've got in $subCategories variable (with foreach loop) it's pure PHP. Link to comment Share on other sites More sharing options...
monish Posted November 25, 2013 Author Share Posted November 25, 2013 Vekia: Sorry to bother you again and again. I am using MegaShop theme and I am getting all the products as subcategories. Now I need to reverse engineer. I need to display products grouped by subcategory. Only question now is how can I check(PHP condition) if a product belongs to a category or not? BTW I have php knowledge, I am only new to PestraShop, its variables and structure. Thanks. Link to comment Share on other sites More sharing options...
monish Posted November 25, 2013 Author Share Posted November 25, 2013 I need a condition to check if a product is part of a subcategory or not. 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