Skip to content

Cannot batch-print invoices from the orders grid #5639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JacobDrummond opened this issue Jul 14, 2016 · 9 comments
Closed

Cannot batch-print invoices from the orders grid #5639

JacobDrummond opened this issue Jul 14, 2016 · 9 comments
Labels
bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update

Comments

@JacobDrummond
Copy link

Steps to reproduce

  1. Install Magento 2.1.0.
  2. Place some orders, and generate some invoices
  3. Verify that the invoices have been generated in Admin > Sales > Operations > Invoices:
    1
  4. Try to batch-print these invoices in Sales > Orders:
    2

Expected result

  1. Invoice Collection rendered as PDF

Actual result

  1. "There are no printable documents related to selected orders":
    3

Problem

  1. The $collection argument passed to Magento\Sales\Controller\Adminhtml\Order\Pdfinvoices::massAction() is an instance of Magento\Sales\Model\ResourceModel\Order\Invoice\Collection.
  2. The line
    $invoicesCollection = $this->collectionFactory->create()->setOrderFilter(['in' => $collection->getAllIds()]); filters $invoicesCollection with setOrderFilter() using a an array of invoice IDs, not order IDs
  3. Apparently it should be $invoicesCollection = $this->collectionFactory->create()->addAttributeToFilter('entity_id', ['in' => $collection->getAllIds()]);.
@maderlock
Copy link

This is a duplicate of an existing issue #4974 which was incorrectly closed, so it's great to see a suggested fix. Hopefully this will get sorted now. I'll give it a test.

@JacobDrummond
Copy link
Author

Hi @maderlock, were you able to replicate the issue, and confirm that the suggested fix works?

@Danielc3
Copy link

The recommended fix on the above post did not work due to an empty collection getting passed into massAction. The issues lies around Magento\Ui\Component\MassAction\Filter. The getCollection function of this class is called within Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction and then this collection is passed into massAction. The issue with what is happening within this getCollection function is that document->getId() returns an order ID, $collection->addFieldToFilter($collection->getIdFieldName(), ['in' => $ids]); is then used, the ID field name being the entity_id. So essentially it ends up filtering an invoice collection by entity IDs, using an array of order IDs. As this is quite an abstract class, the problem most likely revolves around the document itself and what it's ID is set to be. What you end up with is an empty invoice collection by the time you have got to massAction.

@maderlock
Copy link

So I'm guessing that this is not fixed in 2.1.1? It's a major sticking point for clients that rely on the order grid to process orders (as seems reasonable). They currently have to move back and forth between the invoice grid for printing and the order grid for other tasks. Given #6438 on top of this, the invoice grid is hard to use itself if you have customers using PayPal.

Please please put some effort into these order-related bugs.

@JacobDrummond
Copy link
Author

@veloraven, we're approaching the 14-day inactivity cutoff for open issues. Has this issue been replicated by the Magento team?

@pboisvert
Copy link

@JacobDrummond To be clear the 14-day inactivity applies only to issues where Magento has requested more information in order to reproduce an issue. There is no "needs update" label on this issue which indicates we are still investigating and trying to reproduce-so no inactivity clock running on this one.

@davidaddison
Copy link

Do we have a fix on this yet? This one is a big problem for any store with significant order volume.

@sma09sjb
Copy link

sma09sjb commented Dec 1, 2016

Can i get an update on this, we have this exact same problem, i've just debugged and the collection being passed is empty. This is when the grid is filtered by status. The Print All mass action seems to be working strangely.

This is a significant problem, the needs to be looked at as soon as possible.

@oleg-onufer
Copy link
Contributor

oleg-onufer commented Jun 19, 2017

Unfortunately, I could not reproduce the issue as you described it. Can you reproduce this issue on latest version of Magento2?

@magento-engcom-team magento-engcom-team added bug report Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Sep 18, 2017
slavvka pushed a commit to slavvka/magento2 that referenced this issue May 6, 2020
Fixed issues:
- MC-25132: Fix deadlocks related to crons / consumers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update
Projects
None yet
Development

No branches or pull requests

9 participants