hi i have created a custom module in magento. now i need to fetch the order data with user requirement.such as when user enter the from and end date th开发者_如何转开发e only those order id will appear. so i want to run a query in magento which gives me the only those order id. can any one have any idea about this. or please give some suggestion for this
It is very simple...
// 1. Create order collection object
$collection = Mage::getModel('sales/order')->getCollection();
// 2. Apply your date filter
$collection->addFieldToFilter(
'created_at',
array('from' => '2010-01-01', 'to' => '2010-01-01')
);
// 3. Iterate it for displaying results
foreach ($collection as $order) {
//...
}
精彩评论