2

I have a new attribute 'delivered_in' and I'd like to add it to the product page in Magento. I have edited the view.phtml and added the following code:

    <div><p><?php $_product->getResource()->getAttribute('delivered_in')->getFrontend()->getValue($_product);?></p></div>

When I go to the product page I can see the div and p tags are there but the attribute in between doesn't seem to be called (even though it exists within the product).

Can anyone help?

Thank you.

4 Answers 4

1

You forgot echo before the statement. Besides, it can be simplified to:

<div><p><?php echo $_product->getAttributeText('delivered_in') ?></p></div>
2
  • Hello this solution worked for me. Thank you very much, apologies for the late response guys. Thanks for all your help. Commented Jul 21, 2015 at 7:46
  • If it worked for you, please accept the answer, so that it does not count as unanswered anymore for the site statistics (important to get out of beta eventually). magento.stackexchange.com/help/someone-answers Commented Jul 21, 2015 at 7:58
0

Is "Visible on Product View Page on Front-end" set this option to YES ? This option has to be set as yes while creating custom attribute ?

3
  • Yes it is marked a visitble on product view page on front-end. Commented Jul 13, 2015 at 14:10
  • did you tried any other solution mentioned below ? Commented Jul 14, 2015 at 6:49
  • Yes this one worked thanks <div><p><?php echo $_product->getAttributeText('delivered_in') ?></p></div> Commented Jul 21, 2015 at 7:46
0

Try this code.

<?php $product->getResource()->getAttributeRawValue($product->getId(), 'delivered_in', Mage::app()->getStore());?>

We can get any attribute value by this code.

Source : Link

0

Or i'm pretty sure if you have it set to visible on frontend you can use camel case function to get it as:

<div><p><?php echo $_product->getDeliveredIn() ?></p></div>

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.