Jump to content

Display products from all categories under category subheading


Recommended Posts

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

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

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

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