0

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

<?php 
 $_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();?>
Marius
199k55 gold badges431 silver badges837 bronze badges
asked May 22, 2016 at 17:35
2
  • If you use a product attribute then by definition it's not a "static" block. A widget might be more suitable. Commented 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 Commented May 22, 2016 at 19:39

1 Answer 1

0

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

philwinkle
35.8k5 gold badges92 silver badges146 bronze badges
answered May 22, 2016 at 18:43
11
  • 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 Commented 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 Commented May 22, 2016 at 19:03
  • I will try that however, is the code that i have used posted above it it correct? Commented 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. Commented May 22, 2016 at 19:20
  • what would you do differently as my way is not working Commented May 22, 2016 at 19:31

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.