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
<?php
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());
$layout->getUpdate()->addHandle($handlecode);
return $this;
}
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$layout = $observer->getLayout();
$handlecode = 'store_'. strtolower($this->_storeManager->getStore()->getCode());
$layout->getUpdate()->addHandle($handlecode);
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">
<body>
<referenceContainer name="header.container" remove="true" />
<referenceContainer name="footer" remove="true" />
</body>
</page>