Mage_Checkout_Model_Mysql4_Cart Class Reference

Inheritance diagram for Mage_Checkout_Model_Mysql4_Cart:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 getItemsQty ($cart)
 fetchItemsSummaryQty ($quoteId)
 fetchItemsSummary ($quoteId)
 fetchItems ($quoteId)
 addExcludeProductFilter ($collection, $quoteId)

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 28 of file Cart.php.


Member Function Documentation

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 30 of file Cart.php.

00031     {
00032         $this->_init('sales/quote', 'entity_id');
00033     }

addExcludeProductFilter ( collection,
quoteId 
)

Make collection not to load products that are in specified quote

Parameters:
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
int $quoteId

Definition at line 84 of file Cart.php.

00084                                                                    {
00085         $collection->getSelect()->where(new Zend_Db_Expr(sprintf(
00086             'e.entity_id NOT IN (SELECT product_id FROM %s WHERE quote_id=%d)',
00087             $this->getTable('sales/quote_item'), $quoteId
00088         )));
00089     }

fetchItems ( quoteId  ) 

Definition at line 68 of file Cart.php.

00069     {
00070         $read = $this->_getReadAdapter();
00071         $select = $read->select()
00072             ->from(array('qi'=>$this->getTable('sales/quote_item')), array('id'=>'item_id', 'product_id', 'super_product_id', 'qty', 'created_at'))
00073             ->where('qi.quote_id=?', $quoteId);
00074 
00075         return $read->fetchAll($select);
00076     }

fetchItemsSummary ( quoteId  ) 

Definition at line 57 of file Cart.php.

00058     {
00059         $read = $this->_getReadAdapter();
00060         $select = $read->select()
00061             ->from(array('q'=>$this->getTable('sales/quote')), array('items_qty', 'items_count'))
00062             ->where('q.entity_id=?', $quoteId);
00063 
00064         $result = $read->fetchRow($select);
00065         return $result ? $result : array('items_qty'=>0, 'items_count'=>0);
00066     }

fetchItemsSummaryQty ( quoteId  ) 

Definition at line 40 of file Cart.php.

00041     {
00042         $entityType = Mage::getSingleton('eav/config')->getEntityType('quote_item');
00043         $attribute  = Mage::getSingleton('eav/config')->getAttribute($entityType->getEntityTypeId(), 'qty');
00044 
00045         $qtyAttributeTable = $this->getMainTable().'_'.$attribute->getBackendType();
00046         $read = $this->_getReadAdapter();
00047         $select = $read->select()
00048             ->from(array('qty'=>$qtyAttributeTable), 'sum(qty.value)')
00049             ->join(array('e'=>$this->getMainTable()), 'e.entity_id=qty.entity_id', array())
00050             ->where('e.parent_id=?', $quoteId)
00051             ->where('qty.entity_type_id=?', $entityType->getEntityTypeId())
00052             ->where('qty.attribute_id=?', $attribute->getAttributeId());
00053         $qty = $read->fetchOne($select);
00054         return $qty;
00055     }

getItemsQty ( cart  ) 

Definition at line 35 of file Cart.php.

00036     {
00037         return $this->fetchItemsSummaryQty($cart->getQuote()->getId());
00038     }


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

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