Magento Forum

Product Collection count versus getSize
 
mfernandez
Jr. Member
 
Total Posts:  14
Joined:  2009-05-06
 

I try to limit the sales history in the customer dashboard. When i use $order->count i have 10, but with $order->getSize() I have 129 (all customer history). Someone see where the problem is ? This is important because the pagination uses the getSize method.

To prove that the sql is good, I run $orders->getSelectSql(true) outside and i get the correct result.

Thanks for your help.

$orders = Mage::getResourceModel(’sales/order_collection’)
->addAttributeToSelect(’*’)
->joinAttribute(’shipping_firstname’, ‘order_address/firstname’, ‘shipping_address_id’, null, ‘left’)
->joinAttribute(’shipping_lastname’, ‘order_address/lastname’, ‘shipping_address_id’, null, ‘left’)
->addAttributeToFilter(’customer_id’, Mage::getSingleton(’customer/session’)->getCustomer()->getId())
->addAttributeToFilter(’state’, array(’in’ => Mage::getSingleton(’sales/order_config’)->getVisibleOnFrontStates()))
->addAttributeToSort(’created_at’, ‘desc’)
;

$orders->getSelect()->limit(10)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top