GIMLI_2
GIMLI_2

Reputation: 17

Show attribute in product view

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

Answers (2)

digvijay.ocode
digvijay.ocode

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

tricky_spoon
tricky_spoon

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

Related Questions