/** * Re-writes the index entries for all products that are search result of given criteria * * @param MW_Common_Criteria_Interface $search Search criteria * @param array $domains List of domains to be * @param integer $size Size of a chunk of products to handle at a time */ protected function _writeIndex(MW_Common_Criteria_Interface $search, array $domains, $size) { $manager = MShop_Factory::createManager($this->_getContext(), 'product'); $submanagers = $this->_getSubManagers(); $start = 0; do { $search->setSlice($start, $size); $products = $manager->searchItems($search, $domains); $prodIds = array_keys($products); try { $this->begin(); $this->deleteItems($prodIds); foreach ($submanagers as $submanager) { $submanager->rebuildIndex($products); } $this->_saveSubProducts($products); $this->commit(); } catch (Exception $e) { $this->_rollback(); throw $e; } $this->_clearCache($prodIds); $count = count($products); $start += $count; } while ($count == $search->getSliceSize()); }
/** * Initializes the criteria object with the slice based on the given parameter. * * @param MW_Common_Criteria_Interface $criteria Criteria object * @param stdClass $params Object that may contain the properties "condition", "sort", "dir", "start" and "limit" */ private function _initCriteriaSlice(MW_Common_Criteria_Interface $criteria, stdClass $params) { if (isset($params->start) && isset($params->limit)) { $start = isset($params->start) ? $params->start : 0; $size = isset($params->limit) ? $params->limit : 25; $criteria->setSlice($start, $size); } }