8 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
19 private $hashMap = [];
24 private $collectionFactory;
42 CollectionFactory $collectionFactory,
46 $this->collectionFactory = $collectionFactory;
47 $this->hashMapPool = $hashMapPool;
59 if (!isset($this->hashMap[$categoryId])) {
60 $productsCollection = $this->collectionFactory->create();
61 $productsCollection->getSelect()
63 [
'cp' => $this->connection->getTableName(
'catalog_category_product')],
64 'cp.product_id = e.entity_id',
68 $productsCollection->getConnection()->prepareSqlCondition(
71 'in' => $this->hashMapPool->getDataMap(
72 DataCategoryHashMap::class,
74 )->getAllData($categoryId)
77 )->group(
'e.entity_id');
78 $this->hashMap[$categoryId] = $productsCollection->getAllIds();
80 return $this->hashMap[$categoryId];
86 public function getData($categoryId, $key)
88 $categorySpecificData = $this->
getAllData($categoryId);
89 if (isset($categorySpecificData[$key])) {
90 return $categorySpecificData[$key];
100 $this->hashMapPool->resetMap(DataCategoryHashMap::class, $categoryId);
101 unset($this->hashMap[$categoryId]);
__construct(CollectionFactory $collectionFactory, HashMapPool $hashMapPool, ResourceConnection $connection)
getData($categoryId, $key)