public function rebuildStoreSuggestionIndexPage($storeId, $collectionDefault, $page, $pageSize)
{
if ($this->config->isEnabledBackend($storeId) === false) {
$this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($storeId));
return;
}
$collection = clone $collectionDefault;
$collection->setCurPage($page)->setPageSize($pageSize);
$collection->load();
$index_name = $this->suggestion_helper->getIndexName($storeId) . '_tmp';
if ($page == 1) {
$this->algolia_helper->setSettings($index_name, $this->suggestion_helper->getIndexSettings($storeId));
}
$indexData = array();
/** @var Mage_CatalogSearch_Model_Query $suggestion */
foreach ($collection as $suggestion) {
$suggestion->setStoreId($storeId);
$suggestion_obj = $this->suggestion_helper->getObject($suggestion);
if (strlen($suggestion_obj['query']) >= 3) {
array_push($indexData, $suggestion_obj);
}
}
if (count($indexData) > 0) {
$this->algolia_helper->addObjects($indexData, $index_name);
}
unset($indexData);
$collection->walk('clearInstance');
$collection->clear();
unset($collection);
}