0

We are getting fatal error in phtml page after paste this code

$cmsstatic = getResource()->getAttribute('size_chart')->getFrontend()->getValue($_product);
echo $this->getLayout()->createBlock('cms/block')->setBlockID($cmsstatic)->tohtml();

any body can help please

0

You can get the selected frontend Value of size_chart Select box Attribute like below:

$sizeChart = $_product->getAttributeText('size_chart');

Create Static block that have the same identifier as attribute value and usign below code you can show the static block in template

echo $this->getLayout()->createBlock('cms/block')->setBlockId($sizeChart)->toHtml();
  • Hi Pankaj, I am not getting what I am looking for I want to implement a dynamic cms block as per the product as suggested in this link milessebesta.com/web-design/… – Vipin Oct 11 '17 at 5:35
  • I have updated the answer .. hope this help – Pankaj Pareek Oct 11 '17 at 6:05
  • Hi Pankaj, I used below mentioned code but its still not working <?php $sizeChart = $_product->getResource()->getAttribute('size_chart')->getFrontend()->getValue($_product); echo $block->getLayout()->createBlock('cms/block')->setBlockId($sizeChart)->toHtml(); ?> – Vipin Oct 11 '17 at 6:10
  • Can you confirm you are getting the attribute selected value ? – Pankaj Pareek Oct 11 '17 at 6:15
  • No, I am not getting that value, I followed the attached link and pasted your code, but it's throwing the FATAL ERROR, the same which was earlier, I am able to select the static block on backend but on frontend it does not display – Vipin Oct 11 '17 at 6:18

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.