Reputation: 17
I created a custom attibute that contains a string. Now, I want to display it on my product view pages, so I tried to edit the view.phtml file.
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
I tried to do something similar, because the name is also just an attribute, but I don't know how to do it.
Thank you!
Upvotes: 0
Views: 69
Reputation: 46
Please try this. Hope this will work for you.
$attribute = $_product->getResource()->getAttribute('CustomAttributeCode');
if ($attribute)
{
echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}
Upvotes: 1
Reputation: 36
<?php echo $_product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($_product); ?>
just replace "manufacturer" with your Attribute Code
this code will work in view.phtml
Upvotes: 1