0

I want to display cms block if product has the attribute set to yes. A product may have multiple attributes set to yes, and may display multiple cms blocks. Attribute label text will be a BlockId. It may also be another proposed method. How do I see it:

 <?php 
 if(($_product->getAttributeText('*') == "yes")){
 echo $this->getLayout()->createBlock('cms/block')->setBlockID(getAttributeText())->tohtml(); 
 }
 ?>
asked Dec 28, 2021 at 10:21
2
  • Yes, either you can make the above method or use another method like create array on phtml based on that one you can use that things. Commented Dec 28, 2021 at 11:01
  • My method does not work, this is not the correct code Commented Dec 28, 2021 at 15:21

1 Answer 1

1

you need to try this code.

<?php
 if(($_product->getYourCustomattribute()))
 {
 echo $this->getLayout()->createBlock('cms/block')->setBlockID('Your_Block_Id')->tohtml(); 
 }
?>
answered Dec 29, 2021 at 3:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.