8

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"
  }
]
  • Probs just dumb but I don't know what you mean by order status history. Maybe its not something any of my orders have so I don't see it. Can you explain? – jamil Sep 11 '18 at 3:00
  • 1
    @jamil - It's the information in the sales_order_status_history table. I'll add a screenshot to the question. – Enigmativity Sep 11 '18 at 4:21
  • But you didnt ship order? After you ship it will create "complete" ? – BartZalas Sep 11 '18 at 9:03
  • @BartZalas - No, in M2 when you ship an order it doesn't create a record in the sales_order_status_history table. It did in M1, but not M2. Both orders above were shipped orders. – Enigmativity Sep 11 '18 at 10:03
  • I found if you add comment manually in backend => order => information => add comment at the bottom . Its showing on sales_order_status_history but its not showing this default ones. – BartZalas Sep 11 '18 at 10:56
3
+50

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

| improve this answer | |
1

the payment flow and order cycle is the same in both M1 and M2.

When you place an order, you order status will be the one dictated by the payment method used for the order.

  • For instance, check/money order payment method sets the order to pending.
  • Also, most payment methods will set the order status to processing if the payment is physically taken (if capture of the payment was done). In this in case, you should be having an invoice created against this order.
  • Finally, once your order is in processing status, then you need to ship the order (note it is important to verify the shipment is created successfully at this point as otherwise that would explain why your order status is not complete like you expect)

I have tried today on a Magento 2 (2.2.5) and that works as expected. I suggest your environment has a module or customisation that prevents Magento to work as expected. Also, since your post has no answer after 21 days, it seems clear you have to go to the next step:

--> the first thought I have is: are your able to verify the shipment is created successfully in your M2 environment? It is possible your M1 environment was doing the shipment automatically with a module or API integration and M2 needs the shipment created manually for now at least and then you could look at automating this as well

--> If the above is not giving you lights on your issues, I suggest take a look at your server log files and try to find an error that can hint you on what stops Magento to work. Also, Magento logs may be useful of course

enter image description here

I attach here a screenshot showing the shipment creation date. This shows we have a different rendering as M1 but yet the completion date of the order is something that you can read from the shipment creation date?

| improve this answer | |
  • You've missed the point of my question. All of the shipments, invoices, etc, are correctly created. The order status is correct. It's just the order history status record that's not being created in M2 when the order is completed. The screenshots I added to the question should show you what I mean. – Enigmativity Sep 15 '18 at 18:02
  • Hands up, I did look at my local magento 2 instance and the notification is also missing as per your comments. My thought is if you need to fetch the date when the order was marked as complete, it will be match the date when the shipment was created. Of course, you could add a order history notification by implementing a customisation and the latter would create a notification when shipment is created. Do you need this or was it just a curiosity you had? – Herve Tribouilloy Sep 15 '18 at 18:31
  • I need it. Thanks for your second answer. – Enigmativity Sep 16 '18 at 8:15
  • happy to put the full code if you get into trouble, thanks for the feedback – Herve Tribouilloy Sep 16 '18 at 8:16
  • code is available now, see link in the post that I have updated just couple of minutes ago – Herve Tribouilloy Sep 16 '18 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.