From 4ed3b5097eb4e249ec8f82ced493eb83c8ad6294 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Thu, 29 Sep 2016 10:30:36 +0200 Subject: [PATCH] Fix category name retrieval when using flat catalog. --- .../Autocomplete/Category/ItemFactory.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Autocomplete/Category/ItemFactory.php b/src/module-elasticsuite-catalog/Model/Autocomplete/Category/ItemFactory.php index 0718be170..e872e254f 100644 --- a/src/module-elasticsuite-catalog/Model/Autocomplete/Category/ItemFactory.php +++ b/src/module-elasticsuite-catalog/Model/Autocomplete/Category/ItemFactory.php @@ -14,7 +14,7 @@ namespace Smile\ElasticsuiteCatalog\Model\Autocomplete\Category; -use Magento\Catalog\Model\CategoryFactory; +use Magento\Catalog\Model\ResourceModel\Category as CategoryResource; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\UrlInterface; @@ -64,28 +64,28 @@ class ItemFactory extends \Magento\Search\Model\Autocomplete\ItemFactory private $categoryUrlSuffix = null; /** - * @var \Magento\Catalog\Model\CategoryFactory|null + * @var \Magento\Catalog\Model\ResourceModel\Category|null */ - private $categoryFactory = null; + private $categoryResource = null; /** * ItemFactory constructor. * - * @param ObjectManagerInterface $objectManager The Object Manager - * @param UrlInterface $urlBuilder The Url Builder - * @param ScopeConfigInterface $scopeConfig The Scope Config - * @param CategoryFactory $categoryFactory Category Factory + * @param ObjectManagerInterface $objectManager The Object Manager + * @param UrlInterface $urlBuilder The Url Builder + * @param ScopeConfigInterface $scopeConfig The Scope Config + * @param CategoryResource $categoryResource Category Resource Model */ public function __construct( ObjectManagerInterface $objectManager, UrlInterface $urlBuilder, ScopeConfigInterface $scopeConfig, - CategoryFactory $categoryFactory + CategoryResource $categoryResource ) { parent::__construct($objectManager); $this->urlBuilder = $urlBuilder; $this->categoryUrlSuffix = $scopeConfig->getValue(self::XML_PATH_CATEGORY_URL_SUFFIX); - $this->categoryFactory = $categoryFactory; + $this->categoryResource = $categoryResource; } /** @@ -215,8 +215,7 @@ private function getCategoryNameById($categoryId, $storeId) } if (!isset($this->categoryNames[$categoryId])) { - $category = $this->categoryFactory->create(); - $categoryResource = $category->getResource(); + $categoryResource = $this->categoryResource; $this->categoryNames[$categoryId] = $categoryResource->getAttributeRawValue($categoryId, "name", $storeId); }