Mage_Sales_Model_Mysql4_Quote Class Reference

Inheritance diagram for Mage_Sales_Model_Mysql4_Quote:

Mage_Sales_Model_Mysql4_Abstract Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 loadByCustomerId ($quote, $customerId)
 getReservedOrderId ($quote)
 isOrderIncrementIdUsed ($orderIncrementId)
 markQuotesRecollectOnCatalogRules ()
 substractProductFromQuotes ($product)
 markQuotesRecollect ($productIds)

Protected Member Functions

 _construct ()
 _getLoadSelect ($field, $value, $object)


Detailed Description

Definition at line 34 of file Quote.php.


Member Function Documentation

_construct (  )  [protected]

Initialize table nad PK name

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 39 of file Quote.php.

00040     {
00041         $this->_init('sales/quote', 'entity_id');
00042     }

_getLoadSelect ( field,
value,
object 
) [protected]

Retrieve select object for load object data

Parameters:
string $field
mixed $value
Returns:
Zend_Db_Select

For empty result

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 51 of file Quote.php.

00052     {
00053            $select = parent::_getLoadSelect($field, $value, $object);
00054         if ($storeIds = $object->getSharedStoreIds()) {
00055             $select->where('store_id IN (?)', $storeIds);
00056         }
00057         else {
00058             /**
00059              * For empty result
00060              */
00061             $select->where('store_id<0');
00062         }
00063         return $select;
00064     }

getReservedOrderId ( quote  ) 

Definition at line 92 of file Quote.php.

00093     {
00094         return Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($quote->getStoreId());
00095     }

isOrderIncrementIdUsed ( orderIncrementId  ) 

Definition at line 97 of file Quote.php.

00097                                                               {
00098         if ($this->_getReadAdapter()) {
00099             $select = $this->_getReadAdapter()->select();
00100             $select->from($this->getTable('sales/order'), 'entity_id')
00101                 ->where('increment_id = ?', $orderIncrementId);
00102             $entity_id = $this->_getReadAdapter()->fetchOne($select);
00103             if ($entity_id > 0) {
00104                 return true;
00105             } else {
00106                 return false;
00107             }
00108         }
00109         return false;
00110     }

loadByCustomerId ( quote,
customerId 
)

Load quote data by customer identifier

Parameters:
Mage_Sales_Model_Quote $quote
int $customerId

Definition at line 72 of file Quote.php.

00073     {
00074         $read = $this->_getReadAdapter();
00075         if ($read) {
00076             $select = $this->_getLoadSelect('customer_id', $customerId, $quote)
00077                 ->where('is_active=1')
00078                 ->order('updated_at desc')
00079                 ->limit(1);
00080 
00081             $data = $read->fetchRow($select);
00082 
00083             if ($data) {
00084                 $quote->setData($data);
00085             }
00086         }
00087 
00088         $this->_afterLoad($quote);
00089         return $this;
00090     }

markQuotesRecollect ( productIds  ) 

Mark recollect contain product(s) quotes

Parameters:
array|int $productIds
Returns:
Mage_Sales_Model_Mysql4_Quote

Definition at line 151 of file Quote.php.

00152     {
00153         $this->_getWriteAdapter()->query("
00154             UPDATE `{$this->getTable('sales/quote')}` SET `trigger_recollect` = 1
00155             WHERE `entity_id` IN (
00156                 SELECT DISTINCT `quote_id`
00157                 FROM `{$this->getTable('sales/quote_item')}`
00158                 WHERE `product_id` IN (?)
00159             )", $productIds
00160         );
00161 
00162         return $this;
00163     }

markQuotesRecollectOnCatalogRules (  ) 

Mark quotes - that depend on catalog price rules - to be recollected on demand

Definition at line 116 of file Quote.php.

00117     {
00118         $this->_getWriteAdapter()->query("
00119             UPDATE {$this->getTable('sales/quote')} SET trigger_recollect = 1
00120             WHERE entity_id IN (
00121                 SELECT DISTINCT quote_id
00122                 FROM {$this->getTable('sales/quote_item')}
00123                 WHERE product_id IN (SELECT DISTINCT product_id FROM {$this->getTable('catalogrule/rule_product_price')})
00124             )"
00125         );
00126     }

substractProductFromQuotes ( product  ) 

Substract product from all quotes quantities

Parameters:
Mage_Catalog_Model_Product $product

Definition at line 133 of file Quote.php.

00134     {
00135         if ($product->getId()) {
00136             $this->_getWriteAdapter()->query(
00137                 'update ' . $this->getTable('sales/quote_item') .
00138                 ' as qi, ' . $this->getTable('sales/quote') .
00139                 ' as q set q.items_qty = q.items_qty - qi.qty, q.items_count = q.items_count - 1 ' .
00140                 ' where qi.product_id = "' . $product->getId() . '" and q.entity_id = qi.quote_id and qi.parent_item_id is null'
00141             );
00142         }
00143     }


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

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