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); }
protected function _rebuildCategoryIndex($storeId, $categoryIds = null) { if ($categoryIds == null || count($categoryIds) == 0) { $size = $this->category_helper->getCategoryCollectionQuery($storeId, $categoryIds)->getSize(); $by_page = $this->config->getNumberOfElementByPage(); $nb_page = ceil($size / $by_page); for ($i = 1; $i <= $nb_page; $i++) { $data = array('store_id' => $storeId, 'category_ids' => $categoryIds, 'page_size' => $by_page, 'page' => $i); $this->addToQueue('algoliasearch/observer', 'rebuildCategoryIndex', $data, $by_page); } } else { $this->addToQueue('algoliasearch/observer', 'rebuildCategoryIndex', array('store_id' => $storeId, 'category_ids' => $categoryIds), count($categoryIds)); } return $this; }
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; }