scopeConfig = $scopeConfig; } public function getConfig( $path, $storeCode = null ) { $value = $this->scopeConfig->getValue( $path, ScopeInterface::SCOPE_STORE, $storeCode ); if (is_null($value)) { $value = ''; } return $value; } public function execute( Observer $observer ) { if (!$this->getConfig(Helper::XML_ENABLED)) { return; } $layout = $observer->getLayout(); $full_action_name = $observer->getFullActionName(); if ( in_array( $full_action_name, [ 'blog_index_index' ] ) ) { $valueBreadcrumbs = $this->getConfig( 'athlete2_settings/blog/hide_breadcrumbs' ); $valueTitle = $this->getConfig( 'athlete2_settings/blog/hide_title' ); if ( $valueBreadcrumbs ) { $this->removeBlock( 'breadcrumbs', $layout ); } if ( $valueTitle ) { $this->removeBlock( 'page.main.title', $layout ); } } } protected function removeBlock( $name, $layout ) { $block = $layout->getBlock( $name ); if ( $block ) { $layout->unsetElement( $name ); $layout->removeOutputElement( $name ); } } }