Jump to content

[SOLVED]Show products under subcategories on category page


Amazzing

Recommended Posts

Hello,

 

By default, category.tpl displays list of subcategories and then the whole list of products, belonging to parent category.

 

So the page layout is like that:

 

Subcat1

Subcat2

Subcat3

 

list of products belonging to parent category...

 

How can I display products, belonging to subcategories, under subcategory name??

 

What I need is:

 

Subcat1

prod-1-1

prod-2-1

prod-3-1

prod-4-1

 

Subcat2

prod-1-2

prod-2-2

prod-3-2

prod-4-2

 

Subcat3

prod-1-3

prod-2-3

prod-3-3

prod-4-3

 

list of products belonging to parent category...

 

What I found so far:

Obviously we have to add product list inside this loop:

{foreach from=$subcategories item=subcategory}...{/foreach}

 

I tried adding {include file="./product-list.tpl" products=$products}, but it displays all products from parent category under each category.

 

Is it possible to display ./product-list.tpl only for products related to particular subcategory only?

 

Any answers or advices are appreciated.

Link to comment
Share on other sites

You can edit controllers/front/CategoryController.php. Inside this file is supported category page. Find $subcategories variable and add product to subcategory.

After that modification you can edit file category.tpl.

 

Thank you for the advice, but I am not so good at PHP.

 

Ok, I found protected function assignSubcategories() in CategoryController.php

 

What exactly should I do to "and add product to subcategory"?

Link to comment
Share on other sites

  • 2 months later...
  • 1 year 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...