I am new with Magento 2. I wan't to change the page of detailed product: hide Qty box I do that with removing the label and maken an input as hidden. my problem is that I can't arrive to know how to override catalog_product_view.xml correctly.

Here is My code.

    <referenceContainer name="content">
        <container name="product.info.form.content" as="product_info_form_content">
            <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart" as="addtocart" template="Magenticians_AddModule::catalog/product/view/addtocart.phtml"/>

3 Answers 3


Create catalog_product_view.xml like below


and paste the below code to catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="product.info.addtocart" template="Magenticians_AddModule::catalog/product/view/addtocart.phtml"/>

Create catalog_product_view.xml in custom module Path:app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="product.info.addtocart" template="Vendoe_Module::catalog/customaddtocart.phtml"/>
  • thanks for your replay but it does'nt work for me. when i change under /vendeor it works very well but when i try to override and i just copied your code nothing change Aug 14, 2018 at 9:09
  • <?xml version="1.0"?> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="product.info.addtocart"> <action method="setTemplate"> <argument name="template" xsi:type="string">Magenticians_AddModule::catalog/product/view/addtocart.phtml</argument> </action> </referenceBlock> </body> </page> Aug 16, 2018 at 13:50
  • I jsut fixed the problem with this code thanks every body Aug 16, 2018 at 13:51
  • Hi , good to hear that u fixed ur problem using our answer.
    – P Ramulu
    Aug 17, 2018 at 9:09


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.