-1

I want to override catalog_product_view.xml file which is located in

vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml file.

I created below files -

 app/design/frontend/Test/sample/theme.xml  
 app/design/frontend/Test/sample/registration.php
 app/design/frontend/Test/sample/composer.json

app/design/frontend/Test/sample/Magento_Catalog/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.info.sku" remove="true"/>
</body>
</page>
  • @PrincePatel - I have applied theme to one specific product. I am trying to remove sku from product detail page. But it is not getting affected. – jassi Aug 3 '17 at 11:42
1

I recommend reading the Magento devdocs documentation about working with the layout in Magento.

Make sure you understand the difference between overriding and extending layouts in a theme as described in these chapters.

  • I have followed the same but still getting the same error – jassi Aug 3 '17 at 12:36
  • Do you mean you've added the theme under the design configuration for a specific product? In that case could you try to add <referenceContainer name="product.info.stock.sku" remove="true" /> inside the "Layout Update XML" text field under the design tab of the specific product? I'm guessing that the theme is not registered, did you confirm that it appears in the theme table in your database? – c.norin Aug 4 '17 at 6:29
  • I am thanking you so much. It was a great help for me. – jassi Aug 5 '17 at 4:26
0
<Vendor>/<theme>/Magento_Catalog/layout/catalog_product_view.xml

But it's not exactly an ovverride. You can write there only the new rules you need.

  • I want to remove some fields. How to exactly override layout file. – jassi Aug 3 '17 at 10:46
  • You can remove your fields in that file. For example: <referenceBlock name="view.addto.compare" remove="true" /> – nuovecode Aug 3 '17 at 10:48
  • but layout file is not getting called – jassi Aug 3 '17 at 11:46
  • So strange. Have you cleared the cache? – nuovecode Aug 3 '17 at 12:47
  • yes, I have cleared my cache – jassi Aug 4 '17 at 5:17
0

Make sure you have registered and selected your custom theme from CONTENT->configuration

After selecting your custom theme you need to deploy static files by

php bin/magento setup:static-content:deploy

Then create catalog_product_view.xml at app/design/frontend/Test/sample/Magento_Catalog/layout

<?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.info.review" remove="true" />
    </body>
</page>

Now flush cache and try.

  • I have applied theme to one specific product. I am trying to remove sku from product detail page. But it is not getting affected. – jassi Aug 3 '17 at 11:40
  • I tried above solution but still no effect – jassi Aug 3 '17 at 12:00
0

try this following folder

app/design/frontend/Test/sample/Magento_Catalog/layout/override/base/catalog_product_view.xml

after remove this in file

<?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>
       <referenceContainer name="product.info.stock.sku" remove="true" />
</body>
</page>
  • layout file is not getting called – jassi Aug 4 '17 at 5:21
  • @jassi i have update answer check it – Sagar Dobariya Aug 4 '17 at 5:36
  • still its not working – jassi Aug 4 '17 at 5:50
0

In app/design/frontend/Test/sample/Magento_Catalog/layout/catalog_product_view.xml

Please add following content to remove only SKU from Product Detail Page.

<?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.info.stock.sku" remove="true" />
    </body>
</page>

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.