SkyHiRider Posted February 5, 2014 Share Posted February 5, 2014 I would like to display the category of each product that is displayed on the hompege (homefeatured module) right under the price. What is the code that will generate the category name and link to it ? Link to comment Share on other sites More sharing options...
vekia Posted February 5, 2014 Share Posted February 5, 2014 hello and what if product will be associated with several categories? what then? Link to comment Share on other sites More sharing options...
SkyHiRider Posted February 5, 2014 Author Share Posted February 5, 2014 (edited) 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. Edited February 5, 2014 by SkyHiRider (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted February 5, 2014 Share Posted February 5, 2014 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: Link to comment Share on other sites More sharing options...
SkyHiRider Posted February 5, 2014 Author Share Posted February 5, 2014 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 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