We use the following code, to get the last item that was most recent updated.
$itemsCollection = $cart->getQuote()->getItemsCollection();
$itemsCollection->getSelect()->order('updated_at DESC');
$latestItem = $itemsCollection->getLastItem();
But for some reason $latestItem
does not return the last updated item, but the last created_at
item.
How can we solve this?