/**
  * Prepare breadcrumbs
  *
  * @param \Magefan\Blog\Model\Category $category
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return void
  */
 protected function _addBreadcrumbs($category)
 {
     if ($this->_scopeConfig->getValue('web/default/show_cms_breadcrumbs', ScopeInterface::SCOPE_STORE) && ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'))) {
         $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl()]);
         $breadcrumbsBlock->addCrumb('blog', ['label' => __('Blog'), 'title' => __('Go to Blog Home Page'), 'link' => $this->_storeManager->getStore()->getUrl('blog')]);
         $breadcrumbsBlock->addCrumb('blog_category', ['label' => $category->getTitle(), 'title' => $category->getTitle()]);
     }
 }
예제 #2
0
 /**
  * Prepare breadcrumbs
  *
  * @param \Magefan\Blog\Model\Category $category
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return void
  */
 protected function _addBreadcrumbs($category)
 {
     if ($this->_scopeConfig->getValue('web/default/show_cms_breadcrumbs', ScopeInterface::SCOPE_STORE) && ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'))) {
         $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl()]);
         $breadcrumbsBlock->addCrumb('blog', ['label' => __('Blog'), 'title' => __('Go to Blog Home Page'), 'link' => $this->_url->getBaseUrl()]);
         $_category = $category;
         $parentCategories = [];
         while ($parentCategory = $_category->getParentCategory()) {
             $parentCategories[] = $_category = $parentCategory;
         }
         for ($i = count($parentCategories) - 1; $i >= 0; $i--) {
             $_category = $parentCategories[$i];
             $breadcrumbsBlock->addCrumb('blog_parent_category_' . $_category->getId(), ['label' => $_category->getTitle(), 'title' => $_category->getTitle(), 'link' => $_category->getCategoryUrl()]);
         }
         $breadcrumbsBlock->addCrumb('blog_category', ['label' => $category->getTitle(), 'title' => $category->getTitle()]);
     }
 }
 /**
  * Check if current category is child category
  * @param  self  $category
  * @return boolean
  */
 public function isChild($category)
 {
     return $category->isParent($this);
 }
예제 #4
0
 /**
  * After model save
  * @param  \Magefan\Blog\Model\Category $model
  * @param  \Magento\Framework\App\Request\Http $request
  * @return void
  */
 protected function _afterSave($model, $request)
 {
     $model->addData(['parent_id' => $model->getParentId(), 'level' => $model->getLevel()]);
 }