1

I have some attributes that I want to go above the "Add to Cart" button. How can I achieve this?

I followed this tutorial but that didn't work for me -> http://www.dckap.com/blog/display-custom-attribute-value-product-viewlist-page-magento-2/

I am using Magento version 2.1.8

3

Create attr.phtml file and call all your attributes inside that file.

app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/attr.phtml

add your attribute code

<?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getAttributeCode(), 'attribute_code'); ?>

Inside your xml file

app/design/frontend/Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml

<referenceBlock name="product.info.main">
    <block class="Magento\Catalog\Block\Product\View" name="attr" template="product/view/attr.phtml" />
</referenceBlock>

after that move your attr block where ever you want.

for example,

<move element="attr" destination="product.info.main" before="product.info.price" />

let me know if you need any help.

8
  • 1
    Hi. Thanks for your help. It doesn't work for me... I did exactly what you said. Also, why is there $block->getProduct()->getShippingDelivery(), 'shipping_delivery') is that the attribute? I have created a attribute called bottle_size and added it to attribute set called liquid, now I need to bring this attribute in the product view.
    – Greg
    Nov 24 '17 at 14:40
  • You have to call your attribute there... what ever your attribute code Nov 24 '17 at 14:41
  • Could you guide me through it? Been looking for some tutorials but can't find anything :/
    – Greg
    Nov 24 '17 at 14:43
  • what are your attribute codes? Nov 24 '17 at 14:45
  • I created a new product attribute with code bottle_size
    – Greg
    Nov 24 '17 at 14:47

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.