Mage_Sales_Model_Entity_Quote_Item_Collection Class Reference

Inheritance diagram for Mage_Sales_Model_Entity_Quote_Item_Collection:

Mage_Eav_Model_Entity_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 getStoreId ()
 setQuote ($quote)

Protected Member Functions

 _construct ()
 _afterLoad ()
 _getProductCollection ()

Protected Attributes

 $_quote


Detailed Description

Definition at line 36 of file Collection.php.


Member Function Documentation

_afterLoad (  )  [protected]

Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.

Definition at line 62 of file Collection.php.

00063     {
00064         Varien_Profiler::start('TEST1: '.__METHOD__);
00065         $productCollection = $this->_getProductCollection();
00066         Varien_Profiler::stop('TEST1: '.__METHOD__);
00067         $recollectQuote = false;
00068         foreach ($this as $item) {
00069             Varien_Profiler::start('TEST2: '.__METHOD__);
00070             if ($productCollection) {
00071                 $product = $productCollection->getItemById($item->getProductId());
00072             } else {
00073                 $product = false;
00074             }
00075             if ($this->_quote) {
00076                 $item->setQuote($this->_quote);
00077             }
00078             if (!$product) {
00079                 $item->isDeleted(true);
00080                 $recollectQuote = true;
00081                 continue;
00082             }
00083 
00084             if ($item->getSuperProductId()) {
00085                 $superProduct = $productCollection->getItemById($item->getSuperProductId());
00086                 if (!$superProduct) {
00087                     $item->isDeleted(true);
00088                     $recollectQuote = true;
00089                     continue;
00090                 }
00091             }
00092             else {
00093                 $superProduct = null;
00094             }
00095 
00096             $itemProduct = clone $product;
00097             if ($superProduct) {
00098                 $itemProduct->setSuperProduct($superProduct);
00099                 $item->setSuperProduct($superProduct);
00100             }
00101 
00102             $item->importCatalogProduct($itemProduct);
00103             $item->checkData();
00104             Varien_Profiler::stop('TEST2: '.__METHOD__);
00105         }
00106         if ($recollectQuote && $this->_quote) {
00107             $this->_quote->collectTotals();
00108         }
00109         return $this;
00110     }

_construct (  )  [protected]

Initialize collection

Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.

Definition at line 45 of file Collection.php.

00046     {
00047         $this->_init('sales/quote_item');
00048     }

_getProductCollection (  )  [protected]

Definition at line 112 of file Collection.php.

00113     {
00114         $productIds = array();
00115         foreach ($this as $item) {
00116             $productIds[$item->getProductId()] = $item->getProductId();
00117             if ($item->getSuperProductId()) {
00118                 $productIds[$item->getSuperProductId()] = $item->getSuperProductId();
00119             }
00120             if ($item->getParentProductId()) {
00121                 $productIds[$item->getSuperProductId()] = $item->getParentProductId();
00122             }
00123         }
00124 
00125         if (empty($productIds)) {
00126             return false;
00127         }
00128 
00129         $collection = Mage::getModel('catalog/product')->getCollection()
00130             ->setStoreId($this->getStoreId())
00131             ->addIdFilter($productIds)
00132             ->addAttributeToSelect('*')
00133             ->addStoreFilter()
00134             ->addUrlRewrite();
00135 
00136         if (Mage::app()->useCache('checkout_quote')) {
00137             $collection->initCache(
00138                 $this->_getCacheInstance(),
00139                 $this->_cacheConf['prefix'].'_PRODUCTS',
00140                 $this->_getCacheTags()
00141             );
00142         }
00143 
00144         return $collection;
00145     }

getStoreId (  ) 

Definition at line 50 of file Collection.php.

00051     {
00052         return $this->_quote->getStoreId();
00053     }

setQuote ( quote  ) 

Definition at line 55 of file Collection.php.

00056     {
00057         $this->_quote = $quote;
00058         $this->addAttributeToFilter('parent_id', $quote->getId());
00059         return $this;
00060     }


Member Data Documentation

$_quote [protected]

Definition at line 43 of file Collection.php.


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

Generated on Sat Jul 4 17:24:42 2009 for Magento by  doxygen 1.5.8