0

I installed an extension which works fine on previous versions of Magento 2.2 but does not work on latest versions (e.g. Magento 2.2).

In that extension, they use following code in model to get current order:

$order = $this->_saleCollection->create()->getLastItem(); 

where _saleCollection is an instance of \Magento\Sales\Model\ResourceModel\Order\CollectionFactory.

I debugged this code and found that getLastItem() is causing problem. Could you guys please suggest me why Magento 2.2 is not properly executing this code and suggest some alternate solution?

This line of code actually runs in several locations:

  1. When customer places an order.
  2. When admin opens any order and clicks "send email".

In both scenarios $order contains current instance of order.

1 Answer 1

0

Try this

 $this->_checkoutSession->getQuote()->reserveOrderId(); $order = $this->_checkoutSession->getQuote()->getReservedOrderId(); 
1
  • It does not return correct order id. Commented Mar 8, 2018 at 13:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.