Algolia_Algoliasearch_Helper_Data::rebuildStoreSuggestionIndex PHP Méthode

rebuildStoreSuggestionIndex() public méthode

public rebuildStoreSuggestionIndex ( $storeId )
    public function rebuildStoreSuggestionIndex($storeId)
    {
        if ($this->config->isEnabledBackend($storeId) === false) {
            $this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($storeId));
            return;
        }
        $collection = $this->suggestion_helper->getSuggestionCollectionQuery($storeId);
        $size = $collection->getSize();
        if ($size > 0) {
            $pages = ceil($size / $this->config->getNumberOfElementByPage());
            $collection->clear();
            $page = 1;
            while ($page <= $pages) {
                $this->rebuildStoreSuggestionIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage());
                $page++;
            }
            unset($indexData);
        }
    }

Usage Example

 public function rebuildSuggestionIndex(Varien_Object $event)
 {
     $storeId = $event->getStoreId();
     $page = $event->getPage();
     $pageSize = $event->getPageSize();
     if (is_null($storeId) && !empty($categoryIds)) {
         foreach (Mage::app()->getStores() as $storeId => $store) {
             if (!$store->getIsActive()) {
                 continue;
             }
             $this->helper->rebuildStoreSuggestionIndex($storeId);
         }
     } else {
         if (!empty($page) && !empty($pageSize)) {
             $this->helper->rebuildStoreSuggestionIndexPage($storeId, $this->suggestion_helper->getSuggestionCollectionQuery($storeId), $page, $pageSize);
         } else {
             $this->helper->rebuildStoreSuggestionIndex($storeId);
         }
     }
     return $this;
 }