Mage_Sales_Model_Mysql4_Order Class Reference

Inheritance diagram for Mage_Sales_Model_Mysql4_Order:

Mage_Eav_Model_Entity_Abstract Mage_Core_Model_Resource_Abstract Mage_Eav_Model_Entity_Interface

List of all members.

Public Member Functions

 __construct ()
 aggregateProductsByTypes ($orderId, $productTypeIds=array(), $isProductTypeIn=false)


Detailed Description

Definition at line 35 of file Order.php.


Constructor & Destructor Documentation

__construct (  ) 

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 38 of file Order.php.

00039     {
00040         $resource = Mage::getSingleton('core/resource');
00041         $this->setType('order');
00042         $read = $resource->getConnection('sales_read');
00043         $write = $resource->getConnection('sales_write');
00044         $this->setConnection($read, $write);
00045     }


Member Function Documentation

aggregateProductsByTypes ( orderId,
productTypeIds = array(),
isProductTypeIn = false 
)

Count existent products of order items by specified product types

Parameters:
int $orderId
array $productTypeIds
bool $isProductTypeIn
Returns:
array

Definition at line 55 of file Order.php.

00056     {
00057         $select = $this->getReadConnection()->select()
00058             ->from(array('o' => $this->getTable('sales/order_item')), new Zend_Db_Expr('o.product_type, COUNT(*)'))
00059             ->joinInner(array('p' => $this->getTable('catalog/product')), 'o.product_id=p.entity_id', array())
00060             ->where('o.order_id=?', $orderId)
00061             ->group('(1)')
00062         ;
00063         if ($productTypeIds) {
00064             $select->where($this->getReadConnection()->quoteInto(
00065                 sprintf('(o.product_type %s (?))', ($isProductTypeIn ? 'IN' : 'NOT IN')),
00066                 $productTypeIds
00067             ));
00068         }
00069         return $this->getReadConnection()->fetchPairs($select);
00070     }


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