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();
_saleCollection is an instance of
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:
- When customer places an order.
- When admin opens any order and clicks "send email".
In both scenarios
$order contains current instance of order.