I have created two stores in Magento2. One is main website and the second one is retailer site. I need to remove the footer section and the navigation bar for my retailer site. I also need to remove the favorites section from the header only for my retailer site.

Please anyone guide me on this.

Any help would be appreciated.


There is another way to can remove the block from the layout.

Create layout unique handle fro each store like store_en , store_retailer, where to assume that the retailer is the store code of your retailer store & `en is default store code.

Add custom layout handle using on layout_load_before.

Observer code

namespace StackExchange\Magento\Observer\Frontend;

class LayoutLoadBefore implements \Magento\Framework\Event\ObserverInterface {

     * @var \Magento\Store\Model\StoreManagerInterface
    private $storeManager;

    public function __construct(
        \Magento\Store\Model\StoreManagerInterface $storeManager
    ) {
        $this->storeManager = $storeManager;

    public function execute(\Magento\Framework\Event\Observer $observer)
        $layout = $observer->getEvent()->getLayout();

        $handlecode ='store_'.strtolower($this->storeManager->getStore()->getCode());
        return $this;


        public function execute(\Magento\Framework\Event\Observer $observer)

               $layout = $observer->getLayout();
           $handlecode = 'store_'. strtolower($this->_storeManager->getStore()->getCode());

           return $this;

After adding this observer, you need to do Cache flush/Di compile.

Now. if you need to create a handler file at app/code/{Vendorname}/{Module Name}/view/frontend/layout/store_{retailerSITEStoreCode}.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">
        <referenceContainer name="header.container" remove="true" />
        <referenceContainer name="footer" remove="true" />
| improve this answer | |
  • Hi Amit after adding your code I am getting this error Warning: Uncaught Exception: Warning: require(/var/www/html/magento2_dev/pub/errors/report.php): failed to open stream: No such file or directory in /var/www/html/ – Amy Jul 29 '19 at 13:20
  • Could you please help me how to resolve this. – Amy Jul 29 '19 at 13:20
  • Still the same error I am receiving. – Amy Jul 29 '19 at 14:12
  • Please check your files/folder permission... – Amit Bera Jul 29 '19 at 14:13
  • Thanks Amit, It is working perfectly fine.. Ur really a genius. – Amy Jul 29 '19 at 16:51

I would recommend creating a child theme for your retailer site and remove elements accordingly.

| improve this answer | |
  • Can you share me some examples, how to create a child theme – Amy Jul 29 '19 at 10:07
  • I have already created a child theme for my main website. – Amy Jul 29 '19 at 10:07

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.