Public Member Functions | |
getStoreId () | |
setQuote ($quote) | |
resetJoinQuotes ($quotesTableName, $productId=null) | |
Protected Member Functions | |
_construct () | |
_afterLoad () | |
_assignOptions () | |
_assignProducts () | |
Protected Attributes | |
$_quote | |
$_productIds = array() |
Definition at line 35 of file Collection.php.
_afterLoad | ( | ) | [protected] |
After load processing
Assign parent items
Assign options and products
Reimplemented from Varien_Data_Collection_Db.
Definition at line 110 of file Collection.php.
00111 { 00112 parent::_afterLoad(); 00113 /** 00114 * Assign parent items 00115 */ 00116 foreach ($this as $item) { 00117 if ($item->getParentItemId()) { 00118 $item->setParentItem($this->getItemById($item->getParentItemId())); 00119 } 00120 if ($this->_quote) { 00121 $item->setQuote($this->_quote); 00122 } 00123 } 00124 00125 /** 00126 * Assign options and products 00127 */ 00128 $this->_assignOptions() 00129 ->_assignProducts(); 00130 return $this; 00131 }
_assignOptions | ( | ) | [protected] |
Add options to items
Definition at line 138 of file Collection.php.
00139 { 00140 $itemIds = array_keys($this->_items); 00141 $optionCollection = Mage::getModel('sales/quote_item_option')->getCollection() 00142 ->addItemFilter($itemIds); 00143 foreach ($this as $item) { 00144 $item->setOptions($optionCollection->getOptionsByItem($item)); 00145 } 00146 $productIds = $optionCollection->getProductIds(); 00147 $this->_productIds = array_merge($this->_productIds, $productIds); 00148 return $this; 00149 }
_assignProducts | ( | ) | [protected] |
Add products to items and item options
Call type specified logic for product associated with quote item
Definition at line 156 of file Collection.php.
00157 { 00158 Varien_Profiler::start('QUOTE:'.__METHOD__); 00159 $productIds = array(); 00160 foreach ($this as $item) { 00161 $productIds[] = $item->getProductId(); 00162 } 00163 $this->_productIds = array_merge($this->_productIds, $productIds); 00164 00165 $productCollection = Mage::getModel('catalog/product')->getCollection() 00166 ->setStoreId($this->getStoreId()) 00167 ->addIdFilter($this->_productIds) 00168 ->addAttributeToSelect(Mage::getSingleton('sales/quote_config')->getProductAttributes()) 00169 ->addOptionsToResult() 00170 ->addStoreFilter() 00171 ->addUrlRewrite(); 00172 00173 Mage::dispatchEvent('sales_quote_item_collection_products_after_load', array('product_collection'=>$productCollection)); 00174 00175 $recollectQuote = false; 00176 foreach ($this as $item) { 00177 00178 if ($product = $productCollection->getItemById($item->getProductId())) { 00179 $product->setCustomOptions(array()); 00180 00181 foreach ($item->getOptions() as $option) { 00182 /** 00183 * Call type specified logic for product associated with quote item 00184 */ 00185 $product->getTypeInstance(true)->assignProductToOption( 00186 $productCollection->getItemById($option->getProductId()), 00187 $option, 00188 $product 00189 ); 00190 } 00191 $item->setProduct($product); 00192 } 00193 else { 00194 $item->isDeleted(true); 00195 $recollectQuote = true; 00196 } 00197 $item->checkData(); 00198 } 00199 00200 if ($recollectQuote && $this->_quote) { 00201 $this->_quote->collectTotals(); 00202 } 00203 Varien_Profiler::stop('QUOTE:'.__METHOD__); 00204 return $this; 00205 }
_construct | ( | ) | [protected] |
Initialize resource model
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 55 of file Collection.php.
00056 { 00057 $this->_init('sales/quote_item'); 00058 }
getStoreId | ( | ) |
resetJoinQuotes | ( | $ | quotesTableName, | |
$ | productId = null | |||
) |
Reset the collection and inner join it to quotes table
Optionally can select items with specified product id only
string | $quotesTableName | |
int | $productId |
Definition at line 92 of file Collection.php.
00093 { 00094 $this->getSelect() 00095 ->reset() 00096 ->from(array('qi' => $this->getResource()->getMainTable()), array('item_id', 'qty', 'quote_id')); 00097 $this->getSelect() 00098 ->joinInner(array('q' => $quotesTableName), 'qi.quote_id=q.entity_id', array('store_id', 'items_qty', 'items_count')); 00099 if ($productId) { 00100 $this->getSelect()->where('qi.product_id=?', $productId); 00101 } 00102 return $this; 00103 }
setQuote | ( | $ | quote | ) |
Set Quote object to Collection
Mage_Sales_Model_Quote | $quote |
Definition at line 76 of file Collection.php.
00077 { 00078 $this->_quote = $quote; 00079 $this->addFieldToFilter('quote_id', $quote->getId()); 00080 return $this; 00081 }
$_productIds = array() [protected] |
Definition at line 49 of file Collection.php.
$_quote [protected] |
Definition at line 42 of file Collection.php.