5

I am overwriting

vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtl

and I tried puting the overriden file in two locations but no chages occur

First:

app/code/<VENDOR_NAME/<MODULE_NAME>/view/frontend/templates/product/attributes.phtml

Having created a module here

Second:

app/design/frontend/<VENDOR_NAME>/<THEME_NAME>/Magento_Catalog/templates/product/view

What am I doing wrong?

2
  • 1
    For an override to happen in a module the path needs to be app/code/{vendor} not app/{vendor}. That might just be a typo in the question though.
    – circlesix
    Feb 10, 2018 at 21:06
  • 2
    @circlesix Yes, it is a typo in the question Feb 11, 2018 at 11:18

1 Answer 1

7
  • Override attributes.phtml with theme

Copy From

vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtml

To

app/design/frontend/{Vendor}/{theme}/Magento_Catalog/templates/product/view/attributes.phtml

  • Override attributes.phtml with custom module

Create catalog_product_view.xml at

app/code/{Vendor}/{Module}/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.attributes">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Prince_Test::product/view/attributes.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Now copy attributes.phtml to

app/code/{Vendor}/{Module}/view/frontend/templates/product/view/attributes.phtml

Now flush cache.

4
  • I thought that for the overriding templates I needed to only edit it from here app/design/frontend/<VENDOR_NAME>/<THEME_NAME>/Magento_Catalog/templates/product/view/attributes.phtl and that for overriding layouts I needed to have a catalog_product_view.xml file. Thank you, it finally worked! Feb 11, 2018 at 11:46
  • Your welcome @KonstantinPatroev Feb 11, 2018 at 15:20
  • @PrincePatel is the referenceblock name anything specific or can it be anything? Mar 14, 2018 at 9:38
  • @JurģisTomsLiepiņš referenceBlock in override file must have the same block name as base file. Mar 14, 2018 at 9:41

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.