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(); 
   }
    ?>
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. Dec 28, 2021 at 11:01
  • My method does not work, this is not the correct code
    – scalpel
    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(); 
    }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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