0

In Magento 2.1 CE, luma theme, I'm trying to add a product attribute called "RRP" (Recommended Retail Price) and like to display it on the frontend product page and in catalog near the other prices. (Existing MSRP function isn't appropriate because i don't use MAP.)

I've added an price-attribute called "RRP" in backend, and there it's visible. In frontend, it's shown in "more information"-tab, but i like to show it near the other prices.

I've tried to call it in "vendor\magento\module-catalog\view\frontend\templates\product\list.phtml" with following code:

<?php echo $_product->getRrp(); ?>

but it's not visible.

Is this the right file and the right code to call the attribute? Or do i have to add something other to call the attribute in frontend?

But price is shown with 4 decimals, for example 10.0000 instead 10.00, and without currency symbol.

code i've used to show the attribute value:

<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp') ?>

to show attribute label also, i've tried following code, but this doesn't work:

<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp'); $_product->getResource()->getAttribute('rrp')->getStoreLabel() ?>

How i could add global currency format to the attribute? And how i could add the attribute label?

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
asked Feb 8, 2017 at 13:32

2 Answers 2

0

To Show Custom Attribute in product list page you can used following code,

<?php echo $_helper->productAttribute($_product, $_product->getRrp(), 'rrp') ?>

Note : Make sure attribute option is visible for product listing page from admin.

answered Feb 8, 2017 at 13:39
2
  • Thanks a lot for your help! Do you know how to add global price format to the attribute also? Commented Feb 10, 2017 at 16:01
  • If above answer help you, please accept. So it will help other in community. And if you required further help you can ask new question. Commented Feb 10, 2017 at 16:26
0

You have to allow this attribute in attribute setting "Show in product list page" to "yes" in attribute setting.

answered Feb 8, 2017 at 13:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.