Reputation: 39
I'm trying to do exporting orders from magento store
$myOrder=Mage::getModel('sales/order');
$orders=Mage::getModel('sales/mysql4_order_collection');
$allIds=$orders->getAllIds();
But it returns all orders to me.
How can i filter orders by state "new"?
I'm trying
$orders->addFieldToFilter('state',Array('eq'=>"new"));
or
$myOrder->setData('state','new');
but magento still returns all orders.
Upvotes: 0
Views: 2819
Reputation: 5381
You should try like this
$order= Mage::getModel('sales/order')->getCollection()->addFieldToFilter('state', 'new');
$allIds = $order->getAllIds();
or you can use
Mage::getModel('sales/order')->getCollection()->addAttributeToSelect("*")->addAttributeToFilter(array(array('attribute'=>'status', 'eq'=>'pending')));
Upvotes: 1
Reputation: 171
I want to clarify more detail. But, that will help to you.
echo "$order->getSelect()->addFieldToFilter('state',Array('eq'=>"new"))->__toString();
this script will print to like that "Select * from your_table where state='new'
";
Then copy result and go to phpmyadmin or workbench. run this query.
Result query will show you right or not.
Hope this help
Upvotes: 0