I'm trying to override how products are displayed adding some stuff. I've already done with the listing page: Created new file on


di.xml telling to use my file and it works. Just copied the method getProductDetailsHtml and modified as I wanted.

But with the single product view, I don't know what I have to override, I'm searching on


But I can't figure out what magento uses for display a single product. How you guys know? what methodology I need to use to figure out these things? For example: "I need to know what magento is doing on this page". It's a nightmare for me browsing on the magento core directories.


To override the product single page, firstly you need to override the catalog_product_view.xml layout file in your custom module or custom theme

Try below code in catalog_product_view.xml file

<?xml version="1.0"?>
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
         <referenceContainer name="content">
            <referenceBlock name="name_of_block_which_you_want_to_override">
                <block class="Vendorname\Module\Block\Blockanme" name="name_display" template="Vendor_Module::yourtemplate.phtml" group="pass_group_name">

Then you need to your create your block and layout file which you mention on above file.

After that clear the cache by running cache:clean command and check

  • Can't I do it like the same way I did with ListProduct? Just overriding a class changing the method they do for display the product? Dec 1 '16 at 16:00
  • Well yes you can do it that way as well. You need to give preference for the same Dec 1 '16 at 16:19

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.