diff --git a/Classes/Domain/Index/TcaIndexer.php b/Classes/Domain/Index/TcaIndexer.php index 0205836..a55d4c5 100644 --- a/Classes/Domain/Index/TcaIndexer.php +++ b/Classes/Domain/Index/TcaIndexer.php @@ -70,6 +70,10 @@ class TcaIndexer implements IndexerInterface $this->logger->info('Start indexing'); foreach ($this->getRecordGenerator() as $records) { $this->logger->debug('Index records.', [$records]); + if ($records === null) { + break; + } + $this->connection->addDocuments($this->tcaTableService->getTableName(), $records); } $this->logger->info('Finish indexing'); @@ -100,13 +104,13 @@ class TcaIndexer implements IndexerInterface /** * @param int $offset * @param int $limit - * @return array + * @return array|null */ protected function getRecords($offset, $limit) { $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( $this->tcaTableService->getFields(), - $this->tcaTableService->getTableName(), + $this->tcaTableService->getTableClause(), $this->tcaTableService->getWhereClause(), '', '', @@ -117,8 +121,6 @@ class TcaIndexer implements IndexerInterface $this->tcaTableService->prepareRecord($record); } - // TODO: Ignore records from sys folder? - return $records; } @@ -130,8 +132,9 @@ class TcaIndexer implements IndexerInterface { $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow( $this->tcaTableService->getFields(), - $this->tcaTableService->getTableName(), - $this->tcaTableService->getWhereClause() . ' AND uid = ' . (int) $identifier + $this->tcaTableService->getTableClause(), + $this->tcaTableService->getWhereClause() + . ' AND ' . $this->tcaTableService->getTableName() . '.uid = ' . (int) $identifier ); $this->tcaTableService->prepareRecord($record); diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index 4cb38f6..5fa8e80 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -76,6 +76,14 @@ class TcaTableService return $this->tableName; } + /** + * @return string + */ + public function getTableClause() + { + return $this->tableName . ' LEFT JOIN pages on ' . $this->tableName . '.pid = pages.uid'; + } + /** * Adjust record accordingly to configuration. * @param array &$record @@ -100,6 +108,10 @@ class TcaTableService $whereClause = '1=1 ' . BackendUtility::BEenableFields($this->tableName) . BackendUtility::deleteClause($this->tableName) + + . BackendUtility::BEenableFields('pages') + . BackendUtility::deleteClause('pages') + . ' AND pages.no_search = 0' ; $this->logger->debug('Generated where clause.', [$this->tableName, $whereClause]); @@ -111,8 +123,8 @@ class TcaTableService */ public function getFields() { - $fields = 'uid,pid,' . implode( - ',', + $fields = array_merge( + ['uid','pid'], array_filter( array_keys($this->tca['columns']), function ($columnName) { @@ -122,8 +134,12 @@ class TcaTableService ) ); + foreach ($fields as $key => $field) { + $fields[$key] = $this->tableName . '.' . $field; + } + $this->logger->debug('Generated fields.', [$this->tableName, $fields]); - return $fields; + return implode(',', $fields); } /**