Jump to content

show product category in homefeatured module


Recommended Posts

hello

 

and what if product will be associated with several categories? what then?

Each product has a preferred (default) category. That category would be displayed.

 

Notice the "self-inking stamps" under the left image (red stamp) and compare it with the other image (default output of homefeatured module) on the right.

post-34484-0-51174000-1391615277_thumb.png

Edited by SkyHiRider (see edit history)
Link to comment
Share on other sites

in this case it's necessary to modify module core or controllers, it's because by default there is no information about product category attached to products array displayed as a featured products.

 

 

 

to homefeatured.php add this function:

    public static function displayCategoryName($id){
        $category = new Category ($id,(int)Context::getContext()->language->id);
        return $category->name;
    }

and in module template file (homefeatured.tpl) you can use this:

<a href="{$link->getCategoryLink($product.id_category_default)}">{HomeFeatured::displayCategoryName($product.id_category_default)}</a>

effect:
q6piVsF.png

Link to comment
Share on other sites

Added it to my site and it works flawlessly. Amazing. thanks Milos! 

 

I wanted to add this feature to my store due to the research mentioned in this article: 

https://baymard.com/blog/featured-products-category-link

 

It's an interesting read (as most articles on that blog are). I'm just starting with e-commerce but the research there was valuable for me so far, hope it helps you too :)

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