/** * 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; }