/** * @param string $index * @param array $filterFields * @param Dimension[] $dimensions * @return void */ public function create($index, array $filterFields, array $dimensions = []) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); if ($filterFields) { $this->createFlatIndex($this->flatScopeResolver->resolve($index, $dimensions), $filterFields); } }
/** * @param string $indexName * @param Dimension[] $dimensions * @param string $expected * @dataProvider resolveDataProvider */ public function testResolve($indexName, array $dimensions, $expected) { $dimensions = array_map(function ($demension) { return $this->createDimension($demension[0], $demension[1]); }, $dimensions); $scope = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->getMockForAbstractClass(); $scope->expects($this->any())->method('getId')->willReturn(1); $this->resource->expects($this->once())->method('getTableName')->willReturnArgument(0); $this->scopeResolver->expects($this->any())->method('getScope')->willReturn($scope); $result = $this->target->resolve($indexName, $dimensions); $this->assertEquals($expected, $result); }
/** * Build index query * * @param RequestInterface $request * @return Select */ public function build(RequestInterface $request) { $searchIndexTable = $this->scopeResolver->resolve($request->getIndex(), $request->getDimensions()); $select = $this->getSelect()->from(['search_index' => $searchIndexTable], ['entity_id' => 'entity_id'])->joinLeft(['cea' => $this->resource->getTableName('catalog_eav_attribute')], 'search_index.attribute_id = cea.attribute_id', []); if ($this->isNeedToAddFilters($request)) { $select->joinLeft(['category_index' => $this->resource->getTableName('catalog_category_product_index')], 'search_index.entity_id = category_index.product_id', [])->joinLeft(['cpie' => $this->resource->getTableName('catalog_product_index_eav')], 'search_index.entity_id = cpie.entity_id AND search_index.attribute_id = cpie.attribute_id', []); } $select = $this->processDimensions($request, $select); $isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE); if ($isShowOutOfStock === false) { $select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.entity_id = stock_index.product_id' . $this->getReadConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), []); $select->where('stock_index.stock_status = ?', 1); } return $select; }
/** * @param string $index * @param Dimension[] $dimensions * @return void */ public function create($index, array $dimensions) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); }