Mage_Bundle_Model_Price_Index Class Reference

Inheritance diagram for Mage_Bundle_Model_Price_Index:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 reindex ($products=null)
 addPriceIndexToCollection ($collection)
 addPriceIndexToProduct ($product)

Protected Member Functions

 _construct ()
 _getResource ()
 _reindexProduct ($productId, $priceType)


Detailed Description

Definition at line 35 of file Index.php.


Member Function Documentation

_construct (  )  [protected]

Initialize resource model

Reimplemented from Varien_Object.

Definition at line 41 of file Index.php.

00042     {
00043         $this->_init('bundle/price_index');
00044     }

_getResource (  )  [protected]

Retrieve resource instance wrapper

Returns:
Mage_Bundle_Model_Mysql4_Price_Index

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 51 of file Index.php.

00052     {
00053         return parent::_getResource();
00054     }

_reindexProduct ( productId,
priceType 
) [protected]

Reindex Product price

Parameters:
int $productId
int $priceType
Returns:
Mage_Bundle_Model_Price_Index

Definition at line 63 of file Index.php.

00064     {
00065         $this->_getResource()->reindexProduct($productId, $priceType);
00066         return $this;
00067     }

addPriceIndexToCollection ( collection  ) 

Add bundle price range index to Product collection

Parameters:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
Returns:
Mage_Bundle_Model_Price_Index

Definition at line 87 of file Index.php.

00088     {
00089         $productObjects = array();
00090         $productIds     = array();
00091         foreach ($collection->getItems() as $product) {
00092             /* @var $product Mage_Catalog_Model_Product */
00093             if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
00094                 $productIds[] = $product->getEntityId();
00095                 $productObjects[$product->getEntityId()] = $product;
00096             }
00097         }
00098         $websiteId  = Mage::app()->getStore($collection->getStoreId())
00099             ->getWebsiteId();
00100         $groupId    = Mage::getSingleton('customer/session')
00101             ->getCustomerGroupId();
00102 
00103         $addOptionsToResult = false;
00104         $prices = $this->_getResource()->loadPriceIndex($productIds, $websiteId, $groupId);
00105         foreach ($productIds as $productId) {
00106             if (isset($prices[$productId])) {
00107                 $productObjects[$productId]
00108                     ->setData('_price_index', true)
00109                     ->setData('_price_index_min_price', $prices[$productId]['min_price'])
00110                     ->setData('_price_index_max_price', $prices[$productId]['max_price']);
00111             }
00112             else {
00113                 $addOptionsToResult = true;
00114             }
00115         }
00116 
00117         if ($addOptionsToResult) {
00118             $collection->addOptionsToResult();
00119         }
00120 
00121         return $this;
00122     }

addPriceIndexToProduct ( product  ) 

Add price index to bundle product after load

Parameters:
Mage_Catalog_Model_Product $product
Returns:
Mage_Bundle_Model_Price_Index

Definition at line 130 of file Index.php.

00131     {
00132         $websiteId  = $product->getStore()->getWebsiteId();
00133         $groupId    = Mage::getSingleton('customer/session')
00134             ->getCustomerGroupId();
00135         $prices = $this->_getResource()
00136             ->loadPriceIndex($product->getId(), $websiteId, $groupId);
00137         if (isset($prices[$product->getId()])) {
00138             $product->setData('_price_index', true)
00139                 ->setData('_price_index_min_price', $prices[$product->getId()]['min_price'])
00140                 ->setData('_price_index_max_price', $prices[$product->getId()]['max_price']);
00141         }
00142         return $this;
00143     }

reindex ( products = null  ) 

Reindex Bundle product Price Index

Parameters:
Mage_Core_Model_Product|Mage_Catalog_Model_Product_Condition_Interface|array|int $products
Returns:
Mage_Bundle_Model_Price_Index

Definition at line 75 of file Index.php.

00076     {
00077         $this->_getResource()->reindex($products);
00078         return $this;
00079     }


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

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