Jump to content

Group Products by Subcategory on Category Page


sandra nanou

Recommended Posts

Hi,

I'd like to display my products grouped by subcategories, just as below:

Men (main category title)

    Shirt (subcategory)

        Product 1 

        Product 2 

        Product 3 

   Pants (subcategory)

        Product 4 

        Product 5 

  etc....

What I have done so far is adding subcategories to category.tpl :

   {if isset($subcategories)}
    <!-- Subcategories -->
    <div id="subcategories">
        <p class="subcategory-heading">{l s='Subcategories'}</p>
        <ul class="clearfix">
            {foreach from=$subcategories item=subcategory}
                <li>
                    <div class="subcategory-image">
                        <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}" title="{$subcategory.name|escape:'html':'UTF-8'}" class="img">
                            {if $subcategory.id_image}
                                <img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'category_default')|escape:'html':'UTF-8'}" alt="{$subcategory.name|escape:'html':'UTF-8'}"/>
                            {else}
                                <img class="replace-2x" src="{$img_cat_dir}{$lang_iso}-default-category_default.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}"/>
                            {/if}
                        </a>
                    </div>
                    <h5><a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'}</a></h5>
                    {if $subcategory.description}
                        <div class="cat_desc">{$subcategory.description}</div>
                    {/if}
                </li>
            {/foreach}
        </ul>
    </div>
   
{/if}

I guess what I have to do now is overriding CategoryController.php to add products informations to my subcategories, but I really don't know how.

Could you please help me?

Thank you!

 

 

 

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