Magento 2.2.5 Order Status – Order Status History Complete No Longer Created

magento-2.2.5magento2order-status

In our M1 site when an order was shipped the status of the order changed to Complete and the Order Status History would get a record showing that the order was Complete.

M1

NB: Note that there is a "Complete" record.

Now in M2, the Order Status History does not get a new record.

M2

NB: No "Complete" record.

Why is that?

Is there any way to make it create this record?

JSON for the example M1 order:

[
  {
    "entity_id": 1235050,
    "parent_id": 444314,
    "is_customer_notified": 2,
    "is_visible_on_front": 0,
    "comment": "Captured amount of $48.38 online. Transaction ID: \"\".",
    "status": "processing",
    "created_at": "2018-08-12T07:48:10",
    "entity_name": "invoice"
  },
  {
    "entity_id": 1235062,
    "parent_id": 444314,
    "is_customer_notified": 1,
    "is_visible_on_front": 0,
    "comment": null,
    "status": "complete",
    "created_at": "2018-08-12T11:39:56",
    "entity_name": "shipment"
  }
]

JSON for the example M2 order:

[
  {
    "entity_id": 1242440,
    "parent_id": 449257,
    "is_customer_notified": null,
    "is_visible_on_front": 0,
    "comment": "Captured amount of $160.90 online. Transaction ID: \"\"",
    "status": "processing",
    "created_at": "2018-09-11T04:08:28",
    "entity_name": "invoice"
  }
]

Best Answer

This is another answer that I hope will put this question to bed.

  • the previous answer shows how M2 has evolved and how it is possible now to see the order history. However, since you do seem to need to see also a notification when you are viewing the order (a bit of nostalgia feeling)

I have written a module that adds a notification when the shipment is created and reproduces what we had in M1

The module uses a plugin afterRegister plugin of the shipment model (see below)

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Sales\Model\Order\Shipment">
        <plugin name="order_shipped" type="Mbs\OrderNotifification\Plugin\ShipmentSavePlugin" sortOrder="999" />
    </type>
</config>


namespace Mbs\OrderNotifification\Plugin;


use Magento\Sales\Api\OrderRepositoryInterface;

class ShipmentSavePlugin
{
    /**
     * @var OrderRepositoryInterface
     */
    private $orderRepository;

    public function __construct(
        \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
    ) {
        $this->orderRepository = $orderRepository;
    }

    public function afterRegister(\Magento\Sales\Model\Order\Shipment $shipment)
    {
        try {
            $order = $this->orderRepository->get($shipment->getOrderId());
            $order->addStatusHistoryComment('Order Complete', \Magento\Sales\Model\Order::STATE_COMPLETE);
        } catch (\Exception $e) {

        }
    }
}

see full code at order notification repo