Mage_CatalogIndex_Model_Indexer Class Reference

Inheritance diagram for Mage_CatalogIndex_Model_Indexer:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 cleanup ($product)
 plainReindex ($products=null, $attributes=null, $stores=null)
 _walkCollectionRelation ($collection, $store, $attributes=array(), $prices=array())
 getRetreiver ($type)
 queueIndexing ()
 buildEntityPriceFilter ($attributes, $values, &$filteredAttributes, $productCollection)
 buildEntityFilter ($attributes, $values, &$filteredAttributes, $productCollection)
 prepareCatalogProductFlatColumns (Varien_Object $object)
 prepareCatalogProductFlatIndexes (Varien_Object $object)
 updateCatalogProductFlat ($store, $products=null, $resourceTable=null)

Public Attributes

const REINDEX_TYPE_ALL = 0
const REINDEX_TYPE_PRICE = 1
const REINDEX_TYPE_ATTRIBUTE = 2
const STEP_SIZE = 1000

Protected Member Functions

 _construct ()
 _loadIndexers ()
 _getRegisteredIndexers ()
 _getIndexableAttributeCodes ()
 _getStores ()
 _getWebsites ()
 _afterPlainReindex ($store, $products=null)
 _getProductCollection ($store, $products)
 _walkCollection ($collection, $store, $attributes=array(), $prices=array())
 _getPriorifiedProductTypes ()
 _getBaseToSpecifiedCurrencyRate ($code)
 _getSelect ()
 _addFilterableAttributesToCollection ($collection)

Protected Attributes

 $_indexers = array()
 $_priceIndexers = array('price', 'tier_price', 'minimal_price')
 $_attributeIndexers = array('eav')
 $_productTypePriority = null


Detailed Description

Definition at line 35 of file Indexer.php.


Member Function Documentation

_addFilterableAttributesToCollection ( collection  )  [protected]

Add indexable attributes to product collection select

Deprecated:
Parameters:
$collection 
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 749 of file Indexer.php.

00750     {
00751         $attributeCodes = $this->_getIndexableAttributeCodes();
00752         foreach ($attributeCodes as $code) {
00753             $collection->addAttributeToSelect($code);
00754         }
00755 
00756         return $this;
00757     }

_afterPlainReindex ( store,
products = null 
) [protected]

After plain reindex process

Parameters:
Mage_Core_Model_Store|array|int|Mage_Core_Model_Website $store
int|array|Mage_Catalog_Model_Product_Condition_Interface|Mage_Catalog_Model_Product $products
Returns:
Mage_CatalogIndex_Model_Indexer

Catalog Product Flat price update

Definition at line 350 of file Indexer.php.

00351     {
00352         Mage::dispatchEvent('catalogindex_plain_reindex_after', array(
00353             'products' => $products
00354         ));
00355 
00356         /**
00357          * Catalog Product Flat price update
00358          */
00359         if (Mage::helper('catalog/product_flat')->isBuilt()) {
00360             if ($store instanceof Mage_Core_Model_Website) {
00361                 foreach ($store->getStores() as $storeObject) {
00362                     $this->_afterPlainReindex($storeObject->getId(), $products);
00363                 }
00364                 return $this;
00365             }
00366             elseif ($store instanceof Mage_Core_Model_Store) {
00367                 $store = $store->getId();
00368             }
00369             // array of stores
00370             elseif (is_array($store)) {
00371                 foreach ($store as $storeObject) {
00372                     $this->_afterPlainReindex($storeObject->getId(), $products);
00373                 }
00374                 return $this;
00375             }
00376 
00377             $this->updateCatalogProductFlat($store, $products);
00378         }
00379 
00380         return $this;
00381     }

_construct (  )  [protected]

Initialize all indexers and resource model

Reimplemented from Varien_Object.

Definition at line 77 of file Indexer.php.

00078     {
00079         $this->_loadIndexers();
00080         $this->_init('catalogindex/indexer');
00081     }

_getBaseToSpecifiedCurrencyRate ( code  )  [protected]

Retrieve Base to Specified Currency Rate

Parameters:
string $code
Returns:
double

Definition at line 563 of file Indexer.php.

00564     {
00565         return Mage::app()->getStore()->getBaseCurrency()->getRate($code);
00566     }

_getIndexableAttributeCodes (  )  [protected]

Get array of attribute codes required for indexing Each indexer type provide his own set of attributes

Returns:
array

Definition at line 118 of file Indexer.php.

00119     {
00120         $result = array();
00121         foreach ($this->_indexers as $indexer) {
00122             $codes = $indexer->getIndexableAttributeCodes();
00123 
00124             if (is_array($codes))
00125                 $result = array_merge($result, $codes);
00126         }
00127         return $result;
00128     }

_getPriorifiedProductTypes (  )  [protected]

Get product types list by type priority type priority is important in index process example: before indexing complex (configurable, grouped etc.) products we have to index all simple products

Returns:
array

Definition at line 541 of file Indexer.php.

00542     {
00543         if (is_null($this->_productTypePriority)) {
00544             $this->_productTypePriority = array();
00545             $config = Mage::getConfig()->getNode('global/catalog/product/type');
00546 
00547             foreach ($config->children() as $type) {
00548                 $typeName = $type->getName();
00549                 $typePriority = (string) $type->index_priority;
00550                 $this->_productTypePriority[$typePriority] = $typeName;
00551             }
00552             ksort($this->_productTypePriority);
00553         }
00554         return $this->_productTypePriority;
00555     }

_getProductCollection ( store,
products 
) [protected]

Return collection with product and store filters

Parameters:
Mage_Core_Model_Store $store
mixed $products
Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection

Definition at line 390 of file Indexer.php.

00391     {
00392         $collection = Mage::getModel('catalog/product')
00393             ->getCollection()
00394             ->setStoreId($store)
00395             ->addStoreFilter($store);
00396         if ($products instanceof Mage_Catalog_Model_Product) {
00397             $collection->addIdFilter($products->getId());
00398         } else if (is_array($products) || is_numeric($products)) {
00399             $collection->addIdFilter($products);
00400         } elseif ($products instanceof Mage_Catalog_Model_Product_Condition_Interface) {
00401             $products->applyToCollection($collection);
00402         }
00403 
00404         return $collection;
00405     }

_getRegisteredIndexers (  )  [protected]

Get all registered in configuration indexers

Returns:
array

Definition at line 101 of file Indexer.php.

00102     {
00103         $result = array();
00104         $indexerRegistry = Mage::getConfig()->getNode('global/catalogindex/indexer');
00105 
00106         foreach ($indexerRegistry->children() as $node) {
00107             $result[$node->getName()] = (string) $node->class;
00108         }
00109         return $result;
00110     }

_getSelect (  )  [protected]

Retrieve SELECT object

Returns:
Varien_Db_Select

Definition at line 737 of file Indexer.php.

00738     {
00739         return $this->_getResource()->getReadConnection()->select();
00740     }

_getStores (  )  [protected]

Retreive store collection

Returns:
array

Definition at line 135 of file Indexer.php.

00136     {
00137         $stores = $this->getData('_stores');
00138         if (is_null($stores)) {
00139             $stores = Mage::app()->getStores();
00140             $this->setData('_stores', $stores);
00141         }
00142         return $stores;
00143     }

_getWebsites (  )  [protected]

Retreive store collection

Returns:
Mage_Core_Model_Mysql4_Store_Collection

Definition at line 150 of file Indexer.php.

00151     {
00152         $websites = $this->getData('_websites');
00153         if (is_null($websites)) {
00154             $websites = Mage::getModel('core/website')->getCollection()->load();
00155             /* @var $stores Mage_Core_Model_Mysql4_Website_Collection */
00156 
00157             $this->setData('_websites', $websites);
00158         }
00159         return $websites;
00160     }

_loadIndexers (  )  [protected]

Create instances of all index types

Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 88 of file Indexer.php.

00089     {
00090         foreach ($this->_getRegisteredIndexers() as $name=>$class) {
00091             $this->_indexers[$name] = Mage::getSingleton($class);
00092         }
00093         return $this;
00094     }

_walkCollection ( collection,
store,
attributes = array(),
prices = array() 
) [protected]

Run indexing process for product collection

Parameters:
Mage_Catalog_Resource_Eav_Mysql4_Product_Collection $collection
mixed $store
array $attributes
array $prices
Returns:
Mage_CatalogIndex_Model_Indexer

Reindex EAV attributes if required

Reindex prices if required

Definition at line 465 of file Indexer.php.

00466     {
00467         $productCount = $collection->getSize();
00468         if (!$productCount) {
00469             return $this;
00470         }
00471 
00472         for ($i=0;$i<$productCount/self::STEP_SIZE;$i++) {
00473             $this->_getResource()->beginTransaction();
00474 
00475             $stepData = $collection->getAllIds(self::STEP_SIZE, $i*self::STEP_SIZE);
00476 
00477             /**
00478              * Reindex EAV attributes if required
00479              */
00480             if (count($attributes)) {
00481                 $this->_getResource()->reindexAttributes($stepData, $attributes, $store);
00482             }
00483 
00484             /**
00485              * Reindex prices if required
00486              */
00487             if (count($prices)) {
00488                 $this->_getResource()->reindexPrices($stepData, $prices, $store);
00489                 $this->_getResource()->reindexTiers($stepData, $store);
00490                 $this->_getResource()->reindexMinimalPrices($stepData, $store);
00491                 $this->_getResource()->reindexFinalPrices($stepData, $store);
00492             }
00493 
00494             Mage::getResourceSingleton('catalog/product')->refreshEnabledIndex($store, $stepData);
00495 
00496             $kill = Mage::getModel('catalogindex/catalog_index_kill_flag')->loadSelf();
00497             if ($kill->checkIsThisProcess()) {
00498                 $this->_getResource()->rollBack();
00499                 $kill->delete();
00500             } else {
00501                 $this->_getResource()->commit();
00502             }
00503         }
00504         return $this;
00505     }

_walkCollectionRelation ( collection,
store,
attributes = array(),
prices = array() 
)

Walk Product Collection for Relation Parent products

Parameters:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
Mage_Core_Model_Store|Mage_Core_Model_Website $store
array $attributes
array $prices
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 416 of file Indexer.php.

00417     {
00418         if ($store instanceof Mage_Core_Model_Website) {
00419             $storeObject = $store->getDefaultStore();
00420         }
00421         elseif ($store instanceof Mage_Core_Model_Store) {
00422             $storeObject = $store;
00423         }
00424 
00425         $statusCond = array(
00426             'in' => Mage::getSingleton('catalog/product_status')->getSaleableStatusIds()
00427         );
00428 
00429         $productCount = $collection->getSize();
00430         $iterateCount = ($productCount / self::STEP_SIZE);
00431         for ($i = 0; $i < $iterateCount; $i++) {
00432             $stepData = $collection
00433                 ->getAllIds(self::STEP_SIZE, $i * self::STEP_SIZE);
00434             foreach ($this->_getPriorifiedProductTypes() as $type) {
00435                 $retriever = $this->getRetreiver($type);
00436                 if (!$retriever->getTypeInstance()->isComposite()) {
00437                     continue;
00438                 }
00439 
00440                 $parentIds = $retriever->getTypeInstance()
00441                     ->getParentIdsByChild($stepData);
00442                 if ($parentIds) {
00443                     $parentCollection = $this->_getProductCollection($storeObject, $parentIds);
00444                     $parentCollection->addAttributeToFilter('status', $statusCond);
00445                     $parentCollection->addFieldToFilter('type_id', $type);
00446                     $this->_walkCollection($parentCollection, $storeObject, $attributes, $prices);
00447 
00448                     $this->_afterPlainReindex($store, $parentIds);
00449                 }
00450             }
00451         }
00452 
00453         return $this;
00454     }

buildEntityFilter ( attributes,
values,
&$  filteredAttributes,
productCollection 
)

Build Entity filter

Parameters:
array $attributes
array $values
array $filteredAttributes
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection
Returns:
array

Definition at line 672 of file Indexer.php.

00673     {
00674         $filter = array();
00675         $store = Mage::app()->getStore()->getId();
00676 
00677         foreach ($attributes as $attribute) {
00678             $code = $attribute->getAttributeCode();
00679             if (isset($values[$code])) {
00680                 foreach ($this->_attributeIndexers as $indexerName) {
00681                     $indexer = $this->_indexers[$indexerName];
00682                     /* @var $indexer Mage_CatalogIndex_Model_Indexer_Abstract */
00683                     if ($indexer->isAttributeIndexable($attribute)) {
00684                         if ($values[$code]) {
00685                             if (isset($values[$code]['from']) && isset($values[$code]['to'])
00686                                 && (!$values[$code]['from'] && !$values[$code]['to'])) {
00687                                 continue;
00688                             }
00689 
00690                             $table = $indexer->getResource()->getMainTable();
00691                             if (!isset($filter[$code])) {
00692                                 $filter[$code] = $this->_getSelect();
00693                                 $filter[$code]->from($table, array('entity_id'));
00694                             }
00695                             if ($indexer->isAttributeIdUsed()) {
00696                                 $filter[$code]->where('attribute_id = ?', $attribute->getId());
00697                             }
00698                             if (is_array($values[$code])) {
00699                                 if (isset($values[$code]['from']) && isset($values[$code]['to'])) {
00700 
00701                                     if ($values[$code]['from']) {
00702                                         if (!is_numeric($values[$code]['from'])) {
00703                                             $values[$code]['from'] = date("Y-m-d H:i:s", strtotime($values[$code]['from']));
00704                                         }
00705 
00706                                         $filter[$code]->where("value >= ?", $values[$code]['from']);
00707                                     }
00708 
00709 
00710                                     if ($values[$code]['to']) {
00711                                         if (!is_numeric($values[$code]['to'])) {
00712                                             $values[$code]['to'] = date("Y-m-d H:i:s", strtotime($values[$code]['to']));
00713                                         }
00714                                         $filter[$code]->where("value <= ?", $values[$code]['to']);
00715                                     }
00716                                 } else {
00717                                     $filter[$code]->where('value in (?)', $values[$code]);
00718                                 }
00719                             } else {
00720                                 $filter[$code]->where('value = ?', $values[$code]);
00721                             }
00722                             $filter[$code]->where('store_id = ?', $store);
00723                             $filteredAttributes[]=$code;
00724                         }
00725                     }
00726                 }
00727             }
00728         }
00729         return $filter;
00730     }

buildEntityPriceFilter ( attributes,
values,
&$  filteredAttributes,
productCollection 
)

Build Entity price filter

Parameters:
array $attributes
array $values
array $filteredAttributes
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection
Returns:
array

Definition at line 577 of file Indexer.php.

00578     {
00579         $additionalCalculations = array();
00580         $filter = array();
00581         $store = Mage::app()->getStore()->getId();
00582         $website = Mage::app()->getStore()->getWebsiteId();
00583 
00584         $currentStoreCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();
00585 
00586         foreach ($attributes as $attribute) {
00587             $code = $attribute->getAttributeCode();
00588             if (isset($values[$code])) {
00589                 foreach ($this->_priceIndexers as $indexerName) {
00590                     $indexer = $this->_indexers[$indexerName];
00591                     /* @var $indexer Mage_CatalogIndex_Model_Indexer_Abstract */
00592                     if ($indexer->isAttributeIndexable($attribute)) {
00593                         if ($values[$code]) {
00594                             if (isset($values[$code]['from']) && isset($values[$code]['to'])
00595                                 && (strlen($values[$code]['from']) == 0 && strlen($values[$code]['to']) == 0)) {
00596                                 continue;
00597                             }
00598                             $table = $indexer->getResource()->getMainTable();
00599                             if (!isset($filter[$code])) {
00600                                 $filter[$code] = $this->_getSelect();
00601                                 $filter[$code]->from($table, array('entity_id'));
00602                                 $filter[$code]->distinct(true);
00603 
00604                                 $response = new Varien_Object();
00605                                 $response->setAdditionalCalculations(array());
00606                                 $args = array(
00607                                     'select'=>$filter[$code],
00608                                     'table'=>$table,
00609                                     'store_id'=>$store,
00610                                     'response_object'=>$response,
00611                                 );
00612                                 Mage::dispatchEvent('catalogindex_prepare_price_select', $args);
00613                                 $additionalCalculations[$code] = $response->getAdditionalCalculations();
00614 
00615                                 if ($indexer->isAttributeIdUsed()) {
00616                                     $filter[$code]->where("$table.attribute_id = ?", $attribute->getId());
00617                                 }
00618                             }
00619                             if (is_array($values[$code])) {
00620                                 $rateConversion = 1;
00621                                 $filter[$code]->distinct(true);
00622 
00623                                 if (isset($values[$code]['from']) && isset($values[$code]['to'])) {
00624                                     if (isset($values[$code]['currency'])) {
00625                                         $rateConversion = $this->_getBaseToSpecifiedCurrencyRate($values[$code]['currency']);
00626                                     } else {
00627                                         $rateConversion = $this->_getBaseToSpecifiedCurrencyRate($currentStoreCurrency);
00628                                     }
00629 
00630                                     if (strlen($values[$code]['from'])>0) {
00631                                         $filter[$code]->where(
00632                                             "($table.value".implode('', $additionalCalculations[$code]).")*{$rateConversion} >= ?",
00633                                             $values[$code]['from']
00634                                         );
00635                                     }
00636 
00637                                     if (strlen($values[$code]['to'])>0) {
00638                                         $filter[$code]->where(
00639                                             "($table.value".implode('', $additionalCalculations[$code]).")*{$rateConversion} <= ?",
00640                                             $values[$code]['to']
00641                                         );
00642                                     }
00643                                 }
00644                             }
00645                             $filter[$code]->where("$table.website_id = ?", $website);
00646 
00647                             if ($code == 'price') {
00648                                 $filter[$code]->where(
00649                                     $table . '.customer_group_id = ?',
00650                                     Mage::getSingleton('customer/session')->getCustomerGroupId()
00651                                 );
00652                             }
00653 
00654                             $filteredAttributes[]=$code;
00655                         }
00656                     }
00657                 }
00658             }
00659         }
00660         return $filter;
00661     }

cleanup ( product  ) 

Remove index data for specifuc product

Parameters:
mixed $product
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 168 of file Indexer.php.

00168                                       {
00169         $this->_getResource()->clear(true, true, true, true, true, $product);
00170         return $this;
00171     }

getRetreiver ( type  ) 

Retrieve Data retreiver

Parameters:
string $type
Returns:
Mage_CatalogIndex_Model_Data_Abstract

Definition at line 513 of file Indexer.php.

00514     {
00515         return Mage::getSingleton('catalogindex/retreiver')->getRetreiver($type);
00516     }

plainReindex ( products = null,
attributes = null,
stores = null 
)

Reindex catalog product data which used in layered navigation and in product list

Parameters:
mixed $products
mixed $attributes
mixed $stores
Returns:
Mage_CatalogIndex_Model_Indexer

Check indexer flag

Collect initialization data

Prepare stores and websites information

Prepare attributes data

Delete index data

Process index price data per each website (prices depends from website level)

It can happens when website with store was created but store view not yet

Process EAV attributes per each store view

Catalog Product Flat price update

Definition at line 181 of file Indexer.php.

00182     {
00183         /**
00184          * Check indexer flag
00185          */
00186         $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf();
00187         if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING) {
00188             return $this;
00189         }
00190         /*if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED)*/
00191         else {
00192             $flag->setState(Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING)->save();
00193         }
00194 
00195         try {
00196             /**
00197              * Collect initialization data
00198              */
00199             $websites = array();
00200             $attributeCodes = $priceAttributeCodes = array();
00201 //            $status = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
00202 //            $visibility = array(
00203 //                Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
00204 //                Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
00205 //                Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH,
00206 //            );
00207 
00208             /**
00209              * Prepare stores and websites information
00210              */
00211             if (is_null($stores)) {
00212                 $stores     = $this->_getStores();
00213                 $websites   = $this->_getWebsites();
00214             }
00215             elseif ($stores instanceof Mage_Core_Model_Store) {
00216                 $websites[] = $stores->getWebsiteId();
00217                 $stores     = array($stores);
00218             }
00219             elseif (is_array($stores)) {
00220                 foreach ($stores as $one) {
00221                     $websites[] = Mage::app()->getStore($one)->getWebsiteId();
00222                 }
00223             }
00224             elseif (!is_array($stores)) {
00225                 Mage::throwException('Invalid stores supplied for indexing');
00226             }
00227 
00228             /**
00229              * Prepare attributes data
00230              */
00231             if (is_null($attributes)) {
00232                 $priceAttributeCodes = $this->_indexers['price']->getIndexableAttributeCodes();
00233                 $attributeCodes = $this->_indexers['eav']->getIndexableAttributeCodes();
00234             }
00235             elseif ($attributes instanceof Mage_Eav_Model_Entity_Attribute_Abstract) {
00236                 if ($this->_indexers['eav']->isAttributeIndexable($attributes)) {
00237                     $attributeCodes[] = $attributes->getAttributeId();
00238                 }
00239                 if ($this->_indexers['price']->isAttributeIndexable($attributes)) {
00240                     $priceAttributeCodes[] = $attributes->getAttributeId();
00241                 }
00242             }
00243             elseif ($attributes == self::REINDEX_TYPE_PRICE) {
00244                 $priceAttributeCodes = $this->_indexers['price']->getIndexableAttributeCodes();
00245             }
00246             elseif ($attributes == self::REINDEX_TYPE_ATTRIBUTE) {
00247                 $attributeCodes = $this->_indexers['eav']->getIndexableAttributeCodes();
00248             }
00249             else {
00250                 Mage::throwException('Invalid attributes supplied for indexing');
00251             }
00252 
00253             /**
00254              * Delete index data
00255              */
00256             $this->_getResource()->clear(
00257                 $attributeCodes,
00258                 $priceAttributeCodes,
00259                 count($priceAttributeCodes)>0,
00260                 count($priceAttributeCodes)>0,
00261                 count($priceAttributeCodes)>0,
00262                 $products,
00263                 $stores
00264             );
00265 
00266             /**
00267              * Process index price data per each website
00268              * (prices depends from website level)
00269              */
00270             foreach ($websites as $website) {
00271                 $ws = Mage::app()->getWebsite($website);
00272                 if (!$ws) {
00273                     continue;
00274                 }
00275 
00276                 $group = $ws->getDefaultGroup();
00277                 if (!$group) {
00278                     continue;
00279                 }
00280 
00281                 $store = $group->getDefaultStore();
00282 
00283                 /**
00284                  * It can happens when website with store was created but store view not yet
00285                  */
00286                 if (!$store) {
00287                     continue;
00288                 }
00289 
00290                 foreach ($this->_getPriorifiedProductTypes() as $type) {
00291                     $collection = $this->_getProductCollection($store, $products);
00292                     $collection->addAttributeToFilter(
00293                         'status',
00294                         array('in'=>Mage::getModel('catalog/product_status')->getSaleableStatusIds())
00295                     );
00296                     $collection->addFieldToFilter('type_id', $type);
00297                     $this->_walkCollection($collection, $store, array(), $priceAttributeCodes);
00298                     if (!is_null($products) && !$this->getRetreiver($type)->getTypeInstance()->isComposite()) {
00299                         $this->_walkCollectionRelation($collection, $ws, array(), $priceAttributeCodes);
00300                     }
00301                 }
00302             }
00303 
00304             /**
00305              * Process EAV attributes per each store view
00306              */
00307             foreach ($stores as $store) {
00308                 foreach ($this->_getPriorifiedProductTypes() as $type) {
00309                     $collection = $this->_getProductCollection($store, $products);
00310                     Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($collection);
00311                     $collection->addFieldToFilter('type_id', $type);
00312 
00313                     $this->_walkCollection($collection, $store, $attributeCodes);
00314                     if (!is_null($products) && !$this->getRetreiver($type)->getTypeInstance()->isComposite()) {
00315                         $this->_walkCollectionRelation($collection, $store, $attributeCodes);
00316                     }
00317                 }
00318             }
00319 
00320             $this->_afterPlainReindex($stores, $products);
00321 
00322             /**
00323              * Catalog Product Flat price update
00324              */
00325             if (Mage::helper('catalog/product_flat')->isBuilt()) {
00326                 foreach ($stores as $store) {
00327                     $this->updateCatalogProductFlat($store, $products);
00328                 }
00329             }
00330 
00331         } catch (Exception $e) {
00332             $flag->delete();
00333             throw $e;
00334         }
00335 
00336         if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING) {
00337             $flag->delete();
00338         }
00339 
00340         return $this;
00341     }

prepareCatalogProductFlatColumns ( Varien_Object object  ) 

Prepare Catalog Product Flat Columns

Parameters:
Varien_Object $object
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 765 of file Indexer.php.

00766     {
00767         $this->_getResource()->prepareCatalogProductFlatColumns($object);
00768 
00769         return $this;
00770     }

prepareCatalogProductFlatIndexes ( Varien_Object object  ) 

Prepare Catalog Product Flat Indexes

Parameters:
Varien_Object $object
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 778 of file Indexer.php.

00779     {
00780         $this->_getResource()->prepareCatalogProductFlatIndexes($object);
00781 
00782         return $this;
00783     }

queueIndexing (  ) 

Set CatalogIndex Flag as queue Indexing

Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 523 of file Indexer.php.

00524     {
00525         Mage::getModel('catalogindex/catalog_index_flag')
00526             ->loadSelf()
00527             ->setState(Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED)
00528             ->save();
00529 
00530         return $this;
00531     }

updateCatalogProductFlat ( store,
products = null,
resourceTable = null 
)

Update price process for catalog product flat

Parameters:
mixed $storeId
string $resourceTable
mixed $products
Returns:
Mage_CatalogIndex_Model_Indexer

Definition at line 793 of file Indexer.php.

00794     {
00795         if ($store instanceof Mage_Core_Model_Store) {
00796             $store = $store->getId();
00797         }
00798         if ($products instanceof Mage_Catalog_Model_Product) {
00799             $products = $products->getId();
00800         }
00801         $this->_getResource()->updateCatalogProductFlat($store, $products, $resourceTable);
00802 
00803         return $this;
00804     }


Member Data Documentation

$_attributeIndexers = array('eav') [protected]

Definition at line 64 of file Indexer.php.

$_indexers = array() [protected]

Definition at line 49 of file Indexer.php.

$_priceIndexers = array('price', 'tier_price', 'minimal_price') [protected]

Definition at line 56 of file Indexer.php.

$_productTypePriority = null [protected]

Definition at line 71 of file Indexer.php.

const REINDEX_TYPE_ALL = 0

Definition at line 37 of file Indexer.php.

Definition at line 39 of file Indexer.php.

const REINDEX_TYPE_PRICE = 1

Definition at line 38 of file Indexer.php.

const STEP_SIZE = 1000

Definition at line 41 of file Indexer.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:46 2009 for Magento by  doxygen 1.5.8