Actually, I created a multi-vendor site. I did most of the things but now am stuck in invoice creation.
I filter the invoice items in the New Invoice page shown in the screenshot enter image description here

In this order, there are 4 Items but I already filter each vendor can see own items.
In this screenshort, you can see 2 items because the current login vendor has 2 items in this order.

My Problem is when I click on "submit invoice" button in this page it creates 4 records mean insert 4 items in sales_invoice_item table. I want to insert just those records that shown in New Invoice Page which I filtered . Others invoice item will be excluded.

How can I make restriction? please guide me. Thanks

  • are you looking for to create multiple invoices for the same order for each vendor with their items? Mar 19 '19 at 7:53
  • first i want to insert just filtered items in sales_invoice_item then i will discuss after .
    – HaFiz Umer
    Mar 19 '19 at 8:06
  • In my opinion it still would be better not to make changes that way but to use quantities as proposed in my answer to a former question magento.stackexchange.com/a/265960/76597 In that way you will not have any impact on order totals and everything would work as you need. If you dont't want to show some items in the form you should rather think about changing the form (i.e. hide rows with qty = 0) than changing the totals calculation.
    – HelgeB
    Mar 19 '19 at 8:07
  • Dear HelgeB ! i will try your this answer beforePrepareInvoice for filtering invoice item. I will give you feed back soon. Thank you
    – HaFiz Umer
    Mar 19 '19 at 8:20

You have to override the controller which is generating the invoice for the order. Following file is doing this


You have to modify the invoiceItems array according to the vendor items

$invoiceItems = isset($invoiceData['items']) ? $invoiceData['items'] : [];

Following line is processing the invoice

$invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);

How to override controller


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.