Skip to content

Magento 2 Save product cost per order

Our product cost change over time, is it posible to save the product cost in the order. Just as the order save the price. This way I can make reports and know the actual cost and revenue of the order.

Ideally then calling something like this:

foreach ($order->getAllItems() as $orderItem) {
   $sku = $orderItem->getSku();
   $cost= $orderItem->getCost();
   $price= $orderItem->getPrice();
}

Thanks