cipraen Posted November 13, 2014 Share Posted November 13, 2014 Hi, I want to exclude products from a category XYZ from being displayed. In products-list.tpl file after this line {foreach from=$products item=product name=products} I want to add an IF clause that checks the products againts their category and if they are not in category XYZ then they get displayed. I'm new to prestashop so how to you get the product category in smarty ? Link to comment Share on other sites More sharing options...
PrestaShopDeveloper Posted November 14, 2014 Share Posted November 14, 2014 You can't do that in the template. You must override the Category::getProducts() method and there to filter them directly in the SQL query. Link to comment Share on other sites More sharing options...
vekia Posted November 14, 2014 Share Posted November 14, 2014 Hi, I want to exclude products from a category XYZ from being displayed. In products-list.tpl file after this line {foreach from=$products item=product name=products} I want to add an IF clause that checks the products againts their category and if they are not in category XYZ then they get displayed. I'm new to prestashop so how to you get the product category in smarty ? are your products associated with several categories ? i mean, is one product associated with more than one category? Link to comment Share on other sites More sharing options...
cipraen Posted November 14, 2014 Author Share Posted November 14, 2014 are your products associated with several categories ? i mean, is one product associated with more than one category? Yes. I have products (lunch A, lunch B, etc.). All lunch products are in the Lunch Category. Some lunch products are in Week 1 Category some are in Week 2 Category. I can hide the Week Category that is not supposed to be active, but in the Lunch Category products from both Week Categories are still shown. This is what I'm trying to achieve. To exclude the products from a certain Category from being shown in the common category. 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