0

I want to show the below code only if product attribute value is not null

The attribute to check is price_range

CURRENT CODE

<p>The price is not available for this product, it is approximately <?php echo $_helper->productAttribute($block->getProduct(), $block->getProduct()->getPriceRange(), 'price_range') ?>*. <i>*Price shown is for guidance purposes only</i>.</p>

Can anyone please suggest an update with an if statement to get this working?

1 Answer 1

3

I assume you just want to see if the data is set against the product before echoing it?

This will depend on if you are getting a collection of products, adding the attribute to select and then looping through them / if you are just on a product page, but the following should work:

<?php if ($block->getProduct()->getPriceRange()): ?>
 //Do things here
<?php endif; ?> 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.