0

I am trying to show an attribute(Text area) in product page. My phtml file to call the attribute is description.phtml :

 <?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
 <h2><?php echo $this->__('Details') ?></h2>
 <div class="std">
 <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
 </div>
<?php endif; ?>

And I create a static block with this code:

<div id="tab1" class="tab active">
 <p> {{block type="core/template" template="page/description.phtml"}<p> 
</div>

Then I called my static block in view.phtml like this:

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('product_details_tab')->toHtml() ?>

where the identifier of the static block is product_details_tab.

Instead of displaying the value given in the attribute field, It is displaying error like:

Fatal error: Call to a member function getDescription() on null.

Help me to resolve this. Where have I went wrong?

Asish Hira
1,9911 gold badge18 silver badges39 bronze badges
asked May 14, 2016 at 10:20

2 Answers 2

1

You need to replace from $this->getProduct() to Mage::registry('current_product')

For exp :

 <?php $_description = Mage::registry('current_product')->getDescription(); ?>
<?php if ($_description): ?>
 <h2><?php echo $this->__('Details') ?></h2>
 <div class="std">
 <?php echo $this->helper('catalog/output')->productAttribute(Mage::registry('current_product'), $_description, 'description') ?>
 </div>
<?php endif; ?>
answered May 16, 2016 at 5:41
1

You need to change the block type, So replace

<div id="tab1" class="tab active">
 <p> {{block type="core/template" template="page/description.phtml"}<p> 
</div>

with

<div id="tab1" class="tab active">
 <p> {{block type="catalog/product" template="page/description.phtml"}<p> 
</div>

Now your page will find the product blog to get the product.

Hope this will help you

answered May 16, 2016 at 5:45
1
  • Thank you for your guidance. I have upvoted your answer. Commented May 17, 2016 at 8:45

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.