getProductCollectionQuery() public method

public getProductCollectionQuery ( $storeId, $productIds = null, $only_visible = true, $withoutData = false )
示例#1
0
 public function rebuildStoreProductIndex($storeId, $productIds)
 {
     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->product_helper->getProductCollectionQuery($storeId, $productIds, false);
         $size = $collection->getSize();
         if (!empty($productIds)) {
             $size = max(count($productIds), $size);
         }
         $this->logger->log('Store ' . $this->logger->getStoreName($storeId) . ' collection size : ' . $size);
         if ($size > 0) {
             $pages = ceil($size / $this->config->getNumberOfElementByPage());
             $page = 1;
             $collection->clear();
             while ($page <= $pages) {
                 $this->rebuildStoreProductIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage(), $emulationInfo, $productIds);
                 $page++;
             }
         }
     } catch (Exception $e) {
         $this->stopEmulation($emulationInfo);
         throw $e;
     }
     $this->stopEmulation($emulationInfo);
 }
示例#2
0
 protected function _rebuildProductIndex($storeId, $productIds = null, $useTmpIndex = false)
 {
     if ($productIds == null || count($productIds) == 0) {
         $collection = $this->product_helper->getProductCollectionQuery($storeId, $productIds, $useTmpIndex);
         $size = $collection->getSize();
         if (!empty($productIds)) {
             $size = max(count($productIds), $size);
         }
         $by_page = $this->config->getNumberOfElementByPage();
         $nb_page = ceil($size / $by_page);
         for ($i = 1; $i <= $nb_page; $i++) {
             $data = array('store_id' => $storeId, 'product_ids' => $productIds, 'page_size' => $by_page, 'page' => $i, 'use_tmp_index' => $useTmpIndex);
             $this->addToQueue('algoliasearch/observer', 'rebuildProductIndex', $data, $by_page);
         }
     } else {
         $this->addToQueue('algoliasearch/observer', 'rebuildProductIndex', array('store_id' => $storeId, 'product_ids' => $productIds), count($productIds));
     }
     return $this;
 }
 public function rebuildProductIndex(Varien_Object $event)
 {
     $storeId = $event->getStoreId();
     $productIds = $event->getProductIds();
     $page = $event->getPage();
     $pageSize = $event->getPageSize();
     $useTmpIndex = (bool) $event->getUseTmpIndex();
     if (is_null($storeId) && !empty($productIds)) {
         foreach (Mage::app()->getStores() as $storeId => $store) {
             if (!$store->getIsActive()) {
                 continue;
             }
             $this->helper->rebuildStoreProductIndex($storeId, $productIds);
         }
     } else {
         if (!empty($page) && !empty($pageSize)) {
             $collection = $this->product_helper->getProductCollectionQuery($storeId, $productIds, $useTmpIndex);
             $this->helper->rebuildStoreProductIndexPage($storeId, $collection, $page, $pageSize, null, $productIds, $useTmpIndex);
         } else {
             $this->helper->rebuildStoreProductIndex($storeId, $productIds);
         }
     }
     return $this;
 }