/** * @param string $index * @param array $fields * @param Dimension[] $dimensions * @return void */ public function create($index, array $fields, array $dimensions = []) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); if ($fields) { $this->createFlatIndex($this->flatScopeResolver->resolve($index, $dimensions), $fields); } }
/** * Retrieve customer IDs for reindex * * @return array */ protected function getCustomerIdsForReindex() { $connection = $this->resource->getConnection(); $gridTableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []); $select = $connection->select()->from($this->resource->getTableName($gridTableName), 'last_visit_at')->order('last_visit_at DESC')->limit(1); $lastVisitAt = $connection->query($select)->fetchColumn(); $select = $connection->select()->from($this->resource->getTableName('customer_log'), 'customer_id')->where('last_login_at > ?', $lastVisitAt); $customerIds = []; foreach ($connection->query($select)->fetchAll() as $row) { $customerIds[] = $row['customer_id']; } return $customerIds; }
/** * @param array $attributes * @return array */ public function filter(array $attributes) { $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); if ($indexer->getState()->getStatus() != StateInterface::STATUS_VALID) { $tableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []); $columns = $this->resource->getConnection()->describeTable($tableName); foreach (array_keys($attributes) as $attributeCode) { if (!isset($columns[$attributeCode])) { unset($attributes[$attributeCode]); } } } return $attributes; }
/** * @param string $index * @param array $fields * @param Dimension[] $dimensions * @return void */ public function create($index, array $fields, array $dimensions = []) { $this->createFlatTable($this->flatScopeResolver->resolve($index, $dimensions), $fields); }