- * @return \Magento\Catalog\Model\Category
- */
- protected function _initCategory()
- {
- $categoryId = (int)$this->getRequest()->getParam('id', false);
- if (!$categoryId) {
- return false;
- }
-
- try {
- $category = $this->categoryRepository->get($categoryId, $this->_storeManager->getStore()->getId());
- } catch (NoSuchEntityException $e) {
- return false;
- }
- if (!$this->_objectManager->get('Magento\Catalog\Helper\Category')->canShow($category)) {
- return false;
- }
- $this->_catalogSession->setLastVisitedCategoryId($category->getId());
- $this->_coreRegistry->register('current_category', $category);
- try {
- $this->_eventManager->dispatch(