Question

How get specific row from sales_order_item by giving item_id?
Which collection use to filter row?
Can anyone guide me ? has any direct or indirect way to fetch sales_order_item record from item_id?

Was it helpful?

Solution

Try using the repository.

use Magento\Sales\Api\OrderItemRepositoryInterface;

/**
 * @var OrderItemRepositoryInterface
 */
private $orderItemRepository;


public function __construct(
    OrderItemRepositoryInterface $orderItemRepository
) {
    $this->orderItemRepository = $orderItemRepository;
}

Now:

$orderItem = $this->orderItemRepository->get(4);
error_log($orderItem->getName());
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top