Exemplo n.º 1
0
 public function getAllIds($limit = null, $offset = null)
 {
     if (!$this->listingProductMode) {
         return parent::getAllIds($limit, $offset);
     }
     // hack for selecting listing product ids instead entity ids
     $idsSelect = clone $this->getSelect();
     $idsSelect->reset(Zend_Db_Select::ORDER);
     $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
     $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
     $idsSelect->reset(Zend_Db_Select::COLUMNS);
     $idsSelect->columns('lp.' . $this->getIdFieldName());
     $idsSelect->limit($limit, $offset);
     $idsSelect->resetJoinLeft();
     return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
 }
 public function getAllIds($limit = null, $offset = null)
 {
     if (!$this->listingProductMode) {
         return parent::getAllIds($limit, $offset);
     }
     // hack for selecting listing product ids instead entity ids
     $idsSelect = clone $this->getSelect();
     $idsSelect->reset(Zend_Db_Select::ORDER);
     $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
     $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
     $idsSelect->columns('lp.' . $this->getIdFieldName());
     $idsSelect->limit($limit, $offset);
     $data = $this->getConnection()->fetchAll($idsSelect, $this->_bindParams);
     $ids = array();
     foreach ($data as $row) {
         $ids[] = $row[$this->getIdFieldName()];
     }
     return $ids;
 }
 /**
  * Walk Product Collection for Relation Parent products
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @param Mage_Core_Model_Store|Mage_Core_Model_Website $store
  * @param array $attributes
  * @param array $prices
  * @return Mage_CatalogIndex_Model_Indexer
  */
 public function _walkCollectionRelation($collection, $store, $attributes = array(), $prices = array())
 {
     if ($store instanceof Mage_Core_Model_Website) {
         $storeObject = $store->getDefaultStore();
     } elseif ($store instanceof Mage_Core_Model_Store) {
         $storeObject = $store;
     }
     $statusCond = array('in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds());
     $productCount = $collection->getSize();
     $iterateCount = $productCount / self::STEP_SIZE;
     for ($i = 0; $i < $iterateCount; $i++) {
         $stepData = $collection->getAllIds(self::STEP_SIZE, $i * self::STEP_SIZE);
         foreach ($this->_getPriorifiedProductTypes() as $type) {
             $retriever = $this->getRetreiver($type);
             if (!$retriever->getTypeInstance()->isComposite()) {
                 continue;
             }
             $parentIds = $retriever->getTypeInstance()->getParentIdsByChild($stepData);
             if ($parentIds) {
                 $parentCollection = $this->_getProductCollection($storeObject, $parentIds);
                 $parentCollection->addAttributeToFilter('status', $statusCond);
                 $parentCollection->addFieldToFilter('type_id', $type);
                 $this->_walkCollection($parentCollection, $storeObject, $attributes, $prices);
                 $this->_afterPlainReindex($store, $parentIds);
             }
         }
     }
     return $this;
 }