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?
2 Answers 2
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; ?>
 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
- 
 Thank you for your guidance. I have upvoted your answer.Ramya– Ramya2016年05月17日 08:45:24 +00:00Commented May 17, 2016 at 8:45