cancel
Showing results for 
Search instead for 
Did you mean: 

If Product Attribute is Equal to

If Product Attribute is Equal to

How do I display something in the category/product pages if the product has an attribute called "condition" and is equal to "used"?

6 REPLIES 6

Re: If Product Attribute is Equal to

@b7itzz You can use the below code for getting the value of condition attribute.

 

$product->getConditon();

OR

$product->getData('condition');

Thanks

Re: If Product Attribute is Equal to

Is it ($product->getData('condition') == 'used'); ?

Re: If Product Attribute is Equal to

@b7itzz yes you can use 

if($product->getData('condition') == 'used'):
//do whatever if the condition is used.
endif;

 

Thanks 

Re: If Product Attribute is Equal to

Thank you. I'll try it tomorrow Smiley Happy

Re: If Product Attribute is Equal to

@b7itzz yeah sure and if you stuck then let me know.

 

If it solves your issue then "Accept it as solution" as it may be useful for others facing the same issue.

 

Thanks

Re: If Product Attribute is Equal to

Unfortunately it ended up not displaying the products on the category pages. I'm trying to add this on /app/design/frontend/*template*/*template_default*/Magento_Catalog/templates/product/price/amount/default.phtml.