0

I have a custom block for my customer/dashboard page, and while everything works, I cannot use the following:

 public function getOrders(){

        $collection = Mage::getResourceModel('sales/order_collection')
            ->addFieldToSelect('*')
            ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
            ->setOrder('created_at', 'desc')
        ;


        return $collection;
    }

I get a blank page if I access this method. I want to load orders and display them on my dashboard. I took this query from the sales order Mage module.

Am I able to access resources from different modules?

Edit:

I limited it to return one order, but no dice.

   $collection = Mage::getResourceModel('sales/order_collection')
            ->addFieldToSelect('*')
            ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
            ->setOrder('created_at', 'desc')
            ->setPageSize(1)
            ->setCurPage(1);
Adam
  • 8,849
  • 16
  • 67
  • 131
  • How many orders are there in your Magento installation? If you have a lot of orders that may also create problem. Or try to enable the error messages and debug the white screen issue. – Mukesh Apr 27 '15 at 08:26
  • Perhaps that the problem. What if I limit the amount of orders returned – Adam Apr 27 '15 at 08:39

1 Answers1

0

Above code is working there is no problem in code,

Now you need to check is you are getting customer id from

Mage::getSingleton('customer/session')->getCustomer()->getId();

If you are getting customer id then error is in other code of you file or another file. It may have syntax error.

Zeeshan
  • 1,659
  • 13
  • 17