Algolia_Algoliasearch_Helper_Data::rebuildStoreCategoryIndex PHP Метод

rebuildStoreCategoryIndex() публичный Метод

public rebuildStoreCategoryIndex ( $storeId, $categoryIds = null )
    public function rebuildStoreCategoryIndex($storeId, $categoryIds = null)
    {
        if ($this->config->isEnabledBackend($storeId) === false) {
            $this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($storeId));
            return;
        }
        $emulationInfo = $this->startEmulation($storeId);
        try {
            $collection = $this->category_helper->getCategoryCollectionQuery($storeId, $categoryIds);
            $size = $collection->getSize();
            if ($size > 0) {
                $pages = ceil($size / $this->config->getNumberOfElementByPage());
                $collection->clear();
                $page = 1;
                while ($page <= $pages) {
                    $this->rebuildStoreCategoryIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage(), $emulationInfo);
                    $page++;
                }
                unset($indexData);
            }
        } catch (Exception $e) {
            $this->stopEmulation($emulationInfo);
            throw $e;
        }
        $this->stopEmulation($emulationInfo);
    }

Usage Example

Пример #1
0
 public function rebuildCategoryIndex(Varien_Object $event)
 {
     $storeId = $event->getStoreId();
     $categoryIds = $event->getCategoryIds();
     $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->rebuildStoreCategoryIndex($storeId, $categoryIds);
         }
     } else {
         if (!empty($page) && !empty($pageSize)) {
             $this->helper->rebuildStoreCategoryIndexPage($storeId, $this->category_helper->getCategoryCollectionQuery($storeId, $categoryIds), $page, $pageSize);
         } else {
             $this->helper->rebuildStoreCategoryIndex($storeId, $categoryIds);
         }
     }
     return $this;
 }