I have this code -

<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getAttributeName(), 'attributename') ?>

But confused with the path where to paste this code to show custom attribute below price on product page.


If you want to show custom Attribute on view page, you can edit ...\theme\layout\catalog_product_view.xml

Find the block with name product.price.final and after this block add below code:

<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.custom" template="product/view/attribute.phtml" after="-">
        <argument name="at_call" xsi:type="string">getCustom</argument>
        <argument name="at_code" xsi:type="string">custom</argument>
        <argument name="css_class" xsi:type="string">custom</argument>
        <argument name="add_attribute" xsi:type="string">itemprop="custom"</argument>

Note: custom is my attribute code, You can change it with your code

Edit I

You can also add phtmllike:

 <referenceContainer name="product.info.price">
     <block class="Magento\Catalog\Block\Product\View" name="my_custom" template="Magento_Catalog::mycustom.phtml">

Create a new mycustom.phtml inside templates folder with following code.

   $product = $block->getProduct(); 
   echo $product->getCustom();

Hope Above will help.

  • Hi @pawan i want to add attribute below Price on Product view Page, i am using ultimo theme and tried to add your code in catalog_product_view.xml layout files but that is not working. Thanks for you help, any other method or file is very helpful for adding custom custom attribute below product price on Product View Page. Regards :) – Vinay Jun 20 '18 at 17:54
  • What is code of your attribute and type ? – Pawan Jun 21 '18 at 3:58
  • Hi @pawan it is text area type attribute which is assigned to all products. We have to show offers (including Images) below price in that attribute. – Vinay Jun 21 '18 at 4:30
  • And what is code ? – Pawan Jun 21 '18 at 4:35
  • <?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getAttributeName(), 'attributename') ?> – Vinay Jun 21 '18 at 4:36

Generally magento use this file to show product price.


So you need to put your code into this file.

NOTE Do not modify core file directly, better way you need to overide this file into your custom extension then put your code into that.

  • i have added code in that file but custom attribute is not showing up below price. Nothing is coming up. – Vinay Jun 20 '18 at 15:54
  • You can some static text, so you get idea the file which are you looking is this. The attribute value do not show that is another things. for that you need to debug that, have get all information of product or not. – Dhiren Vasoya Jun 21 '18 at 3:12

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.