I want invoice item data using order_item_id and I tried using

use Magento\Sales\Api\InvoiceItemRepositoryInterface;
private function getInvoiceItemById($orderItemId)
        return $this->invItemRepository->get($orderItemId);

But i am not getting any data and instead i am facing an error

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Sales\Api\Data\InvoiceItemInterfacePersistor::__construct() must implement interface Magento\Sales\Model\Spi\InvoiceItemResourceInterface, instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Item given, called in /vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /var/generation/Magento/Sales/Api/Data/InvoiceItemInterfacePersistor.php:58 Stack trace: #0 /vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Magento\Sales\Api\Data\InvoiceItemInterfacePersistor->__construct(Object(Magento\Sales\Model\ResourceModel\Order\Invoice\Item), Object(Magento\Sales\Api\Data\InvoiceItemInterfaceFactory), Object(Magento\Framework\App\ResourceConnection))


This seems to an issue related to DI files.

Can you run the following command from the root of the magento project and check if this resolves your problem?

php bin/magento setup:di:compile
| improve this answer | |
  • hi bluscience thanks for the reply but still no luck same issue again. – gajjala sandeep Jan 25 '19 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.