I would like to add attributes into a particular magento static block. Each product has a specific attribute that is assigned to it and I would like to display that attribute into a specific static block.

I have created the attribute set SIZECHART and added women-top, women-bottom and assign to products. I have also created static block women-top, women-bottom. I have a separate static block called SiZE that I would like to display the information on product page when someone is viewing the product. The current code I have is and it not working

   $_prodID = Mage::registry('current_product')->getId();
   $_product = Mage::getModel('catalog/product')->load($_prodID );
<?php $attributeValue = strtolower($product->getAttributeText('sizechart')); ?>
<?php $staticBlockIdentifier = "static_block_".$attributeValue; ?>
<?php echo $this->getLayout()->createBlock("cms/block")->setBlockId(size)->toHtml();?>
  • If you use a product attribute then by definition it's not a "static" block. A widget might be more suitable.
    – scrowler
    May 22, 2016 at 19:12
  • new to magento see the widget settings but I am not sure how i would accomplished what i would like to do, can you indulge me
    – chad
    May 22, 2016 at 19:39

1 Answer 1


Check if the attributive is correctly configured. Check attribute configuration value Visible on Product View Page on Front-end put in YES

  • The configuration that I have is as you stated plus i have the attribute names set as the same names as the static block. The code I have use is posted in view.phtml. However, nothing is displaying in the static block called SIZE on product page
    – chad
    May 22, 2016 at 19:00
  • So if you currently are in the view.phtml no need to create again the product obj. Please try to debug and print in you instance getData() and check if the information is showing of SIZECHART
    – AleGrinGo
    May 22, 2016 at 19:03
  • I will try that however, is the code that i have used posted above it it correct?
    – chad
    May 22, 2016 at 19:14
  • One moment, try to change $product with $_product bc you are creating a new instance of the product ($_product) but not using in the next line when you collect the attribute text value. About how your code is created, well I would have done in other way, first of all what you are creating a new instance of the same product you are in the view.phtml etc.
    – AleGrinGo
    May 22, 2016 at 19:20
  • what would you do differently as my way is not working
    – chad
    May 22, 2016 at 19:31

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.