_catalogData = $catalogData; parent::__construct($context, $data); } /** * Retrieve HTML title value separator (with space) * * @param null|string|bool|int|Store $store * @return string */ public function getTitleSeparator($store = null) { $separator = (string)$this->_scopeConfig->getValue( 'catalog/seo/title_separator', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); return ' ' . $separator . ' '; } /** * Preparing layout * * @return \Magento\Catalog\Block\Breadcrumbs */ protected function _prepareLayout() { if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) { $breadcrumbsBlock->addCrumb( 'home', [ 'label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl() ] ); $title = []; $path = $this->_catalogData->getBreadcrumbPath(); foreach ($path as $name => $breadcrumb) { $breadcrumbsBlock->addCrumb($name, $breadcrumb); $title[] = $breadcrumb['label']; } $this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title))); } return parent::_prepareLayout(); } }