-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCategory.php
37 lines (31 loc) · 1.2 KB
/
Category.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace MageSuite\SeoLinkMasking\Helper;
class Category
{
protected \Magento\Store\Model\StoreManagerInterface $storeManager;
protected \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository;
protected \MageSuite\SeoLinkMasking\Helper\Page $pageHelper;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
\MageSuite\SeoLinkMasking\Helper\Page $pageHelper
) {
$this->storeManager = $storeManager;
$this->categoryRepository = $categoryRepository;
$this->pageHelper = $pageHelper;
}
public function getCategoryEntityForSearchResultPage($category)
{
if ($category && $category->getId()) {
return $category;
}
if ($this->pageHelper->isSearchResultPageAjaxFilterCall() ||
$this->pageHelper->isSearchResultPage() ||
$this->pageHelper->isBrandsIndexPage()
) {
$rootCategoryId = $this->storeManager->getStore()->getRootCategoryId();
return $this->categoryRepository->get($rootCategoryId);
}
return null;
}
}