2

I need to get order collection of last one year, In which I have to show data month wise like

Jan - xxx(Orders)
Feb - xxx(Orders)
3
  • 1
    you can get report from admin section or you want to get it pro-grammatically – Gopal Patel Mar 9 '17 at 6:58
  • I need to go programatically – Ram Pratap Singh Gour Mar 9 '17 at 7:28
  • Want to use data for some custom pages – Ram Pratap Singh Gour Mar 9 '17 at 7:28
8

Try below code

$fromDate = date('Y-m-d H:i:s', strtotime($fromDate));
$toDate = date('Y-m-d H:i:s', strtotime($toDate));

/* Get the collection */
$orders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
    ->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE))->setOrder('created_at', 'ASC');
$archive=array();
foreach ($orders as $order) {
            $tmp=array();
            $time=strtotime($order->getCreatedAt());
            //save Data you want show in $tmp array
            $archive[date("Y",$time)][date("F",$time)][]=$tmp;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.