I'm stuck on trying to create a new order state programmatically.
So far I'm only able to read the currently available states from
\Magento\Sales\Model\Config\Source\Order\Status
I am unable to find a model I can fill let alone some kind of interface, api or Manager for order states.
In magento 1.9 this was done using the following code:
model = Mage::getModel('sales/order_status')->load('error');
$model->setStatus('error');
$model->setLabel('Not Sent To XXX');
$model->save();
$model->assignState(Mage_Sales_Model_Order::STATE_HOLDED, false);
Best Answer
We should take a look some tests:
dev/tests/integration/testsuite/Magento/Payment/_files/order_status.php
We can use Object Manager or inject
Magento\Sales\Model\Order\Status
in the constructor.