Smile\ElasticsuiteThesaurus\Model\ResourceModel\Thesaurus\Collection::loadStores PHP Method

loadStores() private method

Perform operations after collection load
private loadStores ( ) : void
return void
    private function loadStores()
    {
        $itemIds = array_keys($this->_items);
        if (count($itemIds)) {
            $connection = $this->getConnection();
            $select = $connection->select()->from(['thesaurus_entity_store' => $this->getTable(ThesaurusInterface::STORE_TABLE_NAME)])->where('thesaurus_entity_store.' . ThesaurusInterface::THESAURUS_ID . ' IN (?)', $itemIds);
            $result = $connection->fetchPairs($select);
            if ($result) {
                foreach ($this as $item) {
                    $entityId = $item->getData(ThesaurusInterface::THESAURUS_ID);
                    if (!isset($result[$entityId])) {
                        continue;
                    }
                    $storeId = $result[$item->getData(ThesaurusInterface::THESAURUS_ID)];
                    $storeCode = $this->storeManager->getStore($storeId)->getCode();
                    if ($result[$entityId] == 0) {
                        $stores = $this->storeManager->getStores(false, true);
                        $storeId = current($stores)->getId();
                        $storeCode = key($stores);
                    }
                    $item->setData('_first_store_id', $storeId);
                    $item->setData('store_code', $storeCode);
                    $item->setData('store_id', [$result[$entityId]]);
                }
            }
        }
    }