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

3 Answers 3

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 =)

0
1

Try with this:

Mage::registry('current_product')->getAttributeText('custom_attribute');
0
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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.