_scopeConfig = $scopeConfig; $this->_wpHelper = $wpHelper; $this->_request = $request; } public function execute(Observer $observer) { if($this->_isAdvancedSearchResultPage() || !$this->_wpHelper->isEnabled()) { return; } /** @var \Magento\Framework\View\Layout $layout */ $layout = $observer->getLayout(); $wishlistBlock = $layout->getBlock('wishlist_sidebar'); $compareBlock = $layout->getBlock('catalog.compare.sidebar'); $reorderBlock = $layout->getBlock('sale.reorder.sidebar'); $slideMode = $this->_wpHelper->getSlideMode(); if($wishlistBlock) { $showWishlistBlock = $this->_wpHelper->showWishlistBlock(); if (!$showWishlistBlock || $slideMode) { $layout->unsetElement('wishlist_sidebar'); } } if($compareBlock) { $showCompareBlock = $this->_wpHelper->showCompareBlock(); if (!$showCompareBlock || $slideMode) { $layout->unsetElement('catalog.compare.sidebar'); } } if ($reorderBlock) { $showRecentlyOrderedBlock = $this->_wpHelper->showRecentlyOrderedBlock(); if (!$showRecentlyOrderedBlock || $slideMode) { $layout->unsetElement('sale.reorder.sidebar'); } } } /** * @return bool */ protected function _isAdvancedSearchResultPage() { $is = false; $controller = $this->_request->getControllerName(); $action = $this->_request->getActionName(); $route = $this->_request->getRouteName(); if($route == 'catalogsearch' && $controller == 'advanced' && $action == 'result') { $is = true; } return $is; } }