2

I added custom tab in product page and then showed necessary information in custom file with name: customtabinfo.phtml, now i need display attrubutes, but when i try get attribute: <?php echo $_product->getAttributeText('custom_attribute'); ?> - i see error: Fatal error: Call to a member function getAttributeText() on a non-object.

How i can display my attribute? Thanks

2

or can try:

<?php 

$product_id = Mage::registry('current_product')->getId();
$_product=Mage::getModel('catalog/product')->load($product_id);
$attribute = $_product->getResource()->getAttribute('latitude');
if ($attribute)
{
    echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}
?>

it's also working =)

| improve this answer | |
1

Try with this:

Mage::registry('current_product')->getAttributeText('custom_attribute');
| improve this answer | |
1

Normally in your custom block for your phtml you should do

public function getProduct(){
    if(!$this->product){
       $this->product = Mage::registry('current_order');
    }
    return $this->product;
}

Then in your phtml

echo $this->getProduct()->getAttributeText('custom_attribute')
| improve this answer | |

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.