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?

  • 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 '18 at 21:06
  • 2
    @circlesix Yes, it is a typo in the question – Konstantin Patroev Feb 11 '18 at 11:18
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.

| improve this answer | |
  • 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! – Konstantin Patroev Feb 11 '18 at 11:46
  • Your welcome @KonstantinPatroev – Prince Patel Feb 11 '18 at 15:20
  • @PrincePatel is the referenceblock name anything specific or can it be anything? – Jurģis Toms Liepiņš Mar 14 '18 at 9:38
  • @JurģisTomsLiepiņš referenceBlock in override file must have the same block name as base file. – Prince Patel Mar 14 '18 at 9:41

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.