🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Get The Collection of Order Statuses in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Magento 2 platform is capable of hosting a modern E-commerce store with out of the box functionalities and powerful features.

However, the businesses are also innovating and the customers’ expectations are rising each day. To match these expectations and stand apart from the competitors, the store owners demand powerful features and facilities in the store from the Magento 2 developer.

One such similar scenario was when I had to get the collection of order statuses in Magento 2.

I required the order status collection in order to implement an action on the basis of the order status for which I used the below code. Likewise you can also change order status programmatically in Magento 2.

You can also use this solution when you want to perform an action on the condition of the order status. For example, call an API or generate an invoice for the orders with specific order status only.

Method to get the collection of order status in Magento 2:

use Magento\Sales\Model\ResourceModel\Order\Status\Collection as OrderStatusCollection;

private $orderStatusCollection;

public function __construct(OrderStatusCollection $orderStatusCollection)
{
    $this->orderStatusCollection=$orderStatusCollection;
}    

public function getAllOrderStatus(){
    return $this->orderStatusCollection->toOptionArray();
}

That’s it.

Also, feel free to share the solution with fellow Magento 2 developers via social media working to meet the customers’ expectation

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.