I have a specific type of product. And I want to hide the Tabs on product details page for that product specifically. Is it possible and what is the best way to do that.


2 Answers 2


Yes you can achieve this thing by writing small code.

What you can do is add add layout via event layout_load_before, you can use this event to add your dynamic layout.

Here is sample code for you, please modify as per your need, what you can do is create event.xml in your module


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <!-- for differentiate layout.xml on product basis -->
    <event name="layout_load_before">
        <observer name="load_custom_handler" instance="[Vendor]\[Module]\Observer\LayoutLoadBefore" />

In your [Vendor]\[Module]\Observer\LayoutLoadBefore.php file write below code


namespace [Vendor]\[Module]\Observer;

class LayoutLoadBefore implements \Magento\Framework\Event\ObserverInterface
     * @var \Magento\Framework\Registry
    private $registry;

    public function __construct(
       \Magento\Framework\Registry $registry
    ) {
        $this->registry = $registry;

    public function execute(\Magento\Framework\Event\Observer $observer)
        $product = $this->registry->registry('current_product');

        if (!$product) {
          return $this;
        if ($product->getMyvalue()) { // your condition
           $layout = $observer->getLayout();

        return $this;

And now go to [Vendor]\[Module]\view\frontend\layout\your_handler_name.xml file and write your code.

This file only added to your specific condition of product

In your your_handler_name.xml layout file you can remove your tab like

    <referenceBlock name="product.attributes" remove="true" />       

Yes is it possible for Simple and virtual product type,

you can override catalog_product_view_type_simple.xml and catalog_product_view_type_virtual.xml into your theme and juct put this code so it's effected only in simple and virtual product.

    <referenceBlock name="product.attributes" remove="true" />       

Hope it's help you.

  • Your most welcome !!
    – Dhrumin
    Commented Jun 25, 2018 at 6:37

Your Answer

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

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