Jump to content

List of products, condition on category ID (if this category is active)


Asu34

Recommended Posts

Hi there,
I am trying to set up a condition for displaying a field on the products belonging to a category (and if the latter is active)...
This field would be present on the list of products.

Am on PS 1.7...

I have for the moment only a partial solution with

{if  in_array(99 , Product::getProductCategories($product->id|intval))}
    My field
{/if}

But I miss the other condition which is that this category must be activated.

Do you have an idea ?

I thank you in advance

Link to comment
Share on other sites

  • 2 weeks later...

Then this code should be added in the controller displaying the tpl and assigning a tpl variable that will act as a condition to display the content, eg (pseudocode for example):

$category = new Category(99);

if ($category->active) {

$smarty->assign("displayfield", true);

}

 

And in TPL:

 

{if  displayfield && in_array(99 , Product::getProductCategories($product->id|intval))}     My field {/if}

 

Edited by QuickUpdate.net (see edit history)
Link to comment
Share on other sites

il y a 5 minutes, QuickUpdate.net a dit :

Then this code should be added in the controller displaying the tpl and assigning a tpl variable that will act as a condition to display the content.

Exactly, that's why I created this as an override with PrestaShop cache management to avoid too much slowdown during successive tests to this forum member.

  • Like 1
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...