1

How to add attribute to static block. I am not looking for code, but also where put code.
Assume attribute is named test and static block name sttest.
I have search on this, but always get lost on where to add that code.

Thanks

  • specify your magento version. – Dhiren Vasoya Feb 13 '17 at 3:11
  • Also which type of attribute you need to display – Vaibhav Ahalpara Feb 13 '17 at 3:50
  • Let me explain what I’m trying to accomplish. I’m using Magento ver. 1.9.1.0. I want to add a CMS block tab on my product pages. I know how to create a block, and how to add that block to a product pages. The problem is getting the block to show what I want it to. I want to have the block to show the information of an attribute. I understand the code you just provided should be in the block, but that alone is not the only changes that need to be made …right? What else must be done? Thanks. – Michael Feb 17 '17 at 1:57
0

Simply replace every instance of $this->getProduct() with Mage::registry('current_product') inside description.phtml.

Alternative (somewhat cleaner): Make this your first line in description.phtml: <?php $this->setProduct(Mage::registry('current_product')) ?>

| improve this answer | |
0

You can create a block in any of your module and in its corresponding template file you may add/print the attribute test and then call that block in your static pages/block sttest.

{{block class="Vendor\Module\Block\MyBlock" name="testblock" template="attributetest.phtml"}}

You may call the block as mentioned above in your static block in admin area. All you need to do is place this line of code in the content of your static block.

I hope this helps you. Let me know if you have any doubts.

| improve this answer | |
  • Let me explain what I’m trying to accomplish. I’m using Magento ver. 1.9.1.0. I want to add a CMS block tab on my product pages. I know how to create a block, and how to add that block to a product pages. The problem is getting the block to show what I want it to. I want to have the block to show the information of an attribute. I understand the code you just provided should be in the block, but that alone is not the only changes that need to be made …right? What else must be done? Thanks. – Michael Feb 17 '17 at 1:56

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.