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.

1

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

<div><p><?php echo $_product->getAttributeText('delivered_in') ?></p></div>
  • Hello this solution worked for me. Thank you very much, apologies for the late response guys. Thanks for all your help. – YorkieMagento Jul 21 '15 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 – Fabian Schmengler Jul 21 '15 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 ?

  • Yes it is marked a visitble on product view page on front-end. – YorkieMagento Jul 13 '15 at 14:10
  • did you tried any other solution mentioned below ? – Siddharth Vaghasia Jul 14 '15 at 6:49
  • Yes this one worked thanks <div><p><?php echo $_product->getAttributeText('delivered_in') ?></p></div> – YorkieMagento Jul 21 '15 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, privacy policy and cookie policy

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