How do I retrieve a list of Order Statuses allowed for a given Order State?
-
12-12-2019 - |
Question
My understanding of Order States and Order Statuses are that a given Order State can have one or more allowed Statuses. I've found that I can retrieve a list of all Statuses in the system using:
Mage::getSingleton('sales/order_config')->getStatuses();
However I need the list to be limited to statuses valid for a given State.
Solution
It occurred to me that Magento does this when viewing an Order in the backend; specifically the "Comments History" box has a dropdown populated with allowed Statuses for the given state.
Looking into that block turned up this solution:
public function getStatuses()
{
$state = $this->getOrder()->getState();
$statuses = $this->getOrder()->getConfig()->getStateStatuses($state);
return $statuses;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange