Magento – Fetch order status label in custom module configuration

magento2order-status

Magento 2:

I need to fetch all order status labels list (Ex. Processing, Pending, Complete…) in my custom module configuration settings.

I have searched a lot but they give result of sales orders label. But I need all order status labels.

Please take a look on screen shot. I want this red box order status labels. So admin can select multiple order status for further task.

enter image description here

Best Answer

Try below code to get all the Order State and Status code.

$manager = \Magento\Framework\App\ObjectManager::getInstance(); 
$obj = $manager->create('Magento\Sales\Model\ResourceModel\Order\Status\Collection'); 
print_r($obj->toOptionArray());

Hope this helps you.