0

I want to remove media block and product info block from PDP Page of particular product type. If I use in the following way, <referenceBlock name="product.info.media" remove="true" />

then the media block gets removed from all the pages. But it should remove from only particular product type. In block, I made a check for productType in following way,

public function _toHtml()
{
    if (true) {
        return parent::_toHtml();
    }
    return '';
}

But this is not working out. So how can I remove media and info blocks in PDP Page for particular product Type.

2 Answers 2

1

These are total types of product layout:

catalog_product_view_type_simple.xml
catalog_product_view_type_configurable.xml
catalog_product_view_type_grouped.xml
catalog_product_view_type_bundle.xml
catalog_product_view_type_virtual.xml
catalog_product_view_type_downloadable.xml

if you want to remove block particular type make a file in your theme:-

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
 <referenceBlock name="product.info.media.image" remove="true"/>
 <referenceBlock name="product.info.details" remove="true" />
</body>
</page>

After cache flush check it in your browser :-)

2
  • my file name is catalog_product_view_type_bundle.xml. This effect all the prods of same type. May 18, 2018 at 6:40
  • so every bundle product get the same effect @PavanKumar
    – Divyesh
    May 18, 2018 at 6:41
0

Magento 2 provide diffrent xml file for diffrent types of product. You need to put your code into that file and it remove for that.

Diffrent product types file name are here.

 1. catalog_product_view_type_simple.xml
 2. catalog_product_view_type_virtual.xml
 3. catalog_product_view_type_bundle.xml
 4. catalog_product_view_type_configurable.xml
 5. catalog_product_view_type_grouped.xml
2
  • my file name is catalog_product_view_type_bundle.xml. This effect all the prods of same type. May 18, 2018 at 6:40
  • Yes it remove this for all bundel type product, which you have ask into youe question. May 18, 2018 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.