Public Member Functions | |
__construct () | |
aggregateProductsByTypes ($orderId, $productTypeIds=array(), $isProductTypeIn=false) |
Definition at line 35 of file Order.php.
__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 }
aggregateProductsByTypes | ( | $ | orderId, | |
$ | productTypeIds = array() , |
|||
$ | isProductTypeIn = false | |||
) |
Count existent products of order items by specified product types
int | $orderId | |
array | $productTypeIds | |
bool | $isProductTypeIn |
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 }