# Magento 2 - List of Order States and Statuses

I looked for a way to create an option list of order states and statuses but couldn't find a way. I did found something about a statusfactory but couldn't find a way to get a list out of it and especially of the states.

I need a list of available states and a list of available statuses. Can someone help me or point me in the right direction?

• MmynameStackflow, if my answer helped you in any way, please feel free to set as correct :) – Thiago Lima Feb 11 '18 at 11:24

Use Magento\Sales\Model\ResourceModel\Order\Status\Collection class to get status collection

protected $statusCollection; public function __construct( ... \Magento\Sales\Model\ResourceModel\Order\Status\Collection$statusCollection,
...
) {
...
$this->statusCollection =$statusCollection;
...
}

public function getStatusCollection()
{

$collection =$this->statusCollection->toOptionArray();

echo "<pre>";
print_r($collection); }  You can get the list using the class Magento\Sales\Model\ResourceModel\Order\Status\Collection  There you will see also /** * Join order states table * * @return$this
*/
public function joinStates()


and

/**
* Add state code filter to collection
*
* @param string $state * @return$this
*/

Try this class which gives you list of all order status and state Magento\Sales\Model\Config\Source\Order\Status in this class there is a method toOptionArray()