Description
Preconditions
- Magento version 2.1.3, 2.1.6
Steps to reproduce
- Create Order status labels for default frontend store: http://collabshot.com/show/MVB4Tl
- Original status labels (for admin store should be in this table: http://collabshot.com/show/21mPgT
Expected result
When an order is created in the frontend, order status should have e.g. "erp_uploaded" code.
Label in frontend should be Processing, as we added store specific label "Processing" to "sales_order_status_label" table
But label in admin store should be the original label from "sales_order_status" table, which is not the case.
Actual result
In the file: /vendor/magento/module-sales/Model/Order/Status.php:145, the method "getStoreLabel" is trying to fetch a label for current admin store, but always returns the label for "Default" frontend store (which is id=1 in my case).
The reason is because Magento is not loading ADMIN store id but always returns default store id, even inside adminhtml area:
http://collabshot.com/show/Q8KvAK
"$this->_storeManager->getStore($store);" always returns store id=1 instead of store id=0
This makes status labels usage useless either in the frontend, either in admin, this is how above sample statuses look like in admin:
- On sales grid it looks ok: http://collabshot.com/show/jruSTa
- but inside order details screen it looks like this as having frontend label instead of admin store label: http://collabshot.com/show/APuCyI
So, finally, even the source model that is trying to fetch status label is showing Frontend label instead of original admin status label - all because of wrong store id (Default instead of admin) loaded in backend.
Best way to reproduce:
- Create order
- Open edit order page in admin and note "Order Status"
- Go to Admin: Stores>Settings>Order Status and edit row with status that has order
- Change label for Default Store View = "Processing on store view"
- Refresh order edit form
Expected result
Status = "Processing"
Actual result
Status = "Processing on store view"