Description
In the Magento admin the comments history for an order is displayed in two locations - the Information tab and the Comments History tab.
The Information tab correctly sorts the comments (by created_at DESC
and entity_id DESC
)
However the Comments History tab ONLY sorts by created_at
and thus the information can be inaccurate IF there are multiple records per order at the exact same second.
If you are using the Kount module it updates the order status when the order is placed - typically in 1 second or less. Thus this module frequently creates this bug.
The status history collection queries with the correct sorting in vendor/magento/module-sales/Model/Order.php::getStatusHistoryCollection
. But that collection is later resorted in vendor/magento/module-sales/Block/Adminhtml/Order/View/Tab/History.php::getFullHistory
for the Comments History tab and function only sorts by timestamp.
usort($history, [__CLASS__, 'sortHistoryByTimestamp']);
Preconditions (*)
- 2.4.2-p2
Steps to reproduce (*)
- Ensure the database has 2 records recorded at the same timestamp (to the second) for an order in table
sales_order_status_history
- Navigate to the order in the admin
- Select the Comments History tab
Expected result (*)
- The comments would be ordered by
created_at
andentity_id
Actual result (*)
- The comments are ordered by
created_at
only
Here is the database record sorted correctly with created_at DESC
and entity_id DESC
.
mysql> SELECT entity_id, parent_id, created_at, status, comment FROM sales_order_status_history WHERE parent_id = 2225512 ORDER BY created_at DESC, entity_id DESC;
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
| entity_id | parent_id | created_at | status | comment |
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
| 9932939 | 2225512 | 2021-09-09 22:41:35 | complete | Vertex Invoice sent successfully. Amount: $57.90 |
| 9932246 | 2225512 | 2021-09-09 20:00:18 | picking | picking |
| 9932124 | 2225512 | 2021-09-09 19:45:31 | processing | Order status updated from Kount. |
| 9932123 | 2225512 | 2021-09-09 19:45:30 | review_kount | Kount ENS Notification: Modify status of an order by agent. |
| 9931424 | 2225512 | 2021-09-09 16:46:45 | review_kount | Order on review from Kount. |
| 9931423 | 2225512 | 2021-09-09 16:46:45 | processing | Captured amount of $661.60 online. Transaction ID: "5wxpptgs" |
+-----------+-----------+---------------------+--------------+---------------------------------------------------------------+
6 rows in set (0.00 sec)
And on the Information tab you see that the status of Processing
is correctly listed before the status of Review
.
But here on the Comments History tab you can see that the Processing
and Review
statues have been flipped.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status