Stefan Brendle
Stefan Brendle

Reputation: 1564

How to get all Magento Order status (List all magento order status)

How to get a list of all magento order status (pending, complete, processing etc.)?

It should show all values like the "status" drop down field in the order-index grid page in the magento backend.

Upvotes: 2

Views: 15220

Answers (3)

R T
R T

Reputation: 4549

Here is the way to get the output for dop-down:

    $statuses = Mage::getModel('sales/order_status')->getCollection()
                    ->toOptionArray()
    echo '<pre>';print_r($statuses);echo '</pre>';
    //this will output:
    Array
    (
        [0] => Array
            (
                [status] => canceled
                [label] => Canceled
            )

        [1] => Array
            (
                [status] => cancel_ogone
                [label] => Cancelled Ogone
            )

        [2] => Array
            (
                [status] => closed
                [label] => Closed
            )

        [3] => Array
            (
                [status] => complete
                [label] => Complete
            )
    .....

Upvotes: 0

digiswaps
digiswaps

Reputation: 11

Get all order statuses and save the array $orderStatus[status][label] in $status associative array:

$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
$status = array();
$status = array(
    '-1'=>'Please Select..'
);

foreach($orderStatusCollection as $orderStatus) {
    $status[] = array (
        'value' => $orderStatus['status'], 'label' => $orderStatus['label']
    );
}

Upvotes: 1

Stefan Brendle
Stefan Brendle

Reputation: 1564

Just use this simple line of code:

Mage::getModel('sales/order_status')->getResourceCollection()->getData();

For example:

var_dump(   Mage::getModel('sales/order_status')->getResourceCollection()->getData()  );

Result:

array(10) { [0]=> array(2) { ["status"]=> string(8) "canceled" ["label"]=> string(8) "Canceled" } [1]=> array(2) { ["status"]=> string(6) "closed" ["label"]=> string(6) "Closed" } [2]=> array(2) { ["status"]=> string(8) "complete" ["label"]=> string(8) "Complete" } [3]=> array(2) { ["status"]=> string(5) "fraud" ["label"]=> string(15) "Suspected Fraud" } [4]=> array(2) { ["status"]=> string(6) "holded" ["label"]=> string(7) "On Hold" } [5]=> array(2) { ["status"]=> string(14) "payment_review" ["label"]=> string(14) "Payment Review" } [6]=> array(2) { ["status"]=> string(7) "pending" ["label"]=> string(7) "Pending" } [7]=> array(2) { ["status"]=> string(15) "pending_payment" ["label"]=> string(15) "Pending Payment" } [8]=> array(2) { ["status"]=> string(14) "pending_paypal" ["label"]=> string(14) "Pending PayPal" } [9]=> array(2) { ["status"]=> string(10) "processing" ["label"]=> string(10) "Processing" } }

Upvotes: 6

Related Questions