Skip to content
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

Error While send Invoice with Grouped Products #5105

Closed
srbarba opened this issue Jun 20, 2016 · 23 comments
Closed

Error While send Invoice with Grouped Products #5105

srbarba opened this issue Jun 20, 2016 · 23 comments
Assignees
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@srbarba
Copy link

srbarba commented Jun 20, 2016

Steps to reproduce

  1. Install Magento from develop branch.
  2. Add some Grouped Product to cart.
  3. Place an order with the grouped product.
  4. Go to admin.
  5. Go to Sales>Orders and open de current order with the grouped product.
  6. Go to Invoice and select the "Email Copy of Invoice" checkbox.
  7. Press "Submit Invoice".

Expected result

  1. Invoice the order.
  2. Send the copy email to client.

Actual result

  1. Order is invoiced.
  2. An error occurs with the price and send email fails.

The error from report:
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\\Sales\\Block\\Order\\Email\\Items\\Order\\DefaultOrder::getItemPrice() must be an instance of Magento\\Sales\\Model\\Order\\Item, instance of Magento\\Sales\\Model\\Order\\Invoice\\Item given, called in /var/www/vhosts/superpiensos.com/development/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml on line 34 and defined in /var/www/vhosts/superpiensos.com/development/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php:97\nStack trace:\n#0 /var/www/vhosts/superpiensos.com/development/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml(34): Magento\\Sales\\Block\\Order\\Email\\Items\\Order\\DefaultOrder->getItemPrice(Object(Magento\\Sales\\Model\\Order\\Invoice\\Item))\n#1 /var/www/vhosts/superpiensos.com/development/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/vhosts...')\n#2 /var/www/vhosts/superpiensos.com/development/vendor/magento/fr...\n', referer: http://magento.superpiensos.com/admin_superp/sales/order_invoice/new/order_id/92/key/a6d27d6abf43f83c88d6e6be59095107f13ef4b74420fb3697e35953217a52ac/

@NadiyaS NadiyaS added the CS label Jun 21, 2016
@NadiyaS NadiyaS self-assigned this Jun 21, 2016
@Mulderua
Copy link
Contributor

Mulderua commented Jun 21, 2016

Hi @srbarba , we cannot reproduce this scenario on current develop(3561b66).
You could disable all third party extensions, update your version of magento. Do composer install/update. Clear magento cache. Do bin/magento setup:upgrade.
If scenario will be reproducing again. Please add more details to steps for reproduce.
Thank you!

@srbarba
Copy link
Author

srbarba commented Jun 21, 2016

Hello!
I did a new installation(without third party extensions) with Magento 2.0.7v in another server.
The error appears.

Steps:

  1. Install Magento
  2. Create category
  3. Create 2 Simple Products
  4. Create Grouped with this 2 Simple products.
  5. Buy a simple product from the Grouped Product.
  6. Invoice the order at admin with Copy email option checked.

Result:
The error at first comment.

See that video!
https://drive.google.com/file/d/0B3WruH9jln9bVml1aDl5bG0zZW8/view

I tryed without "Autosettings" changes(at simple product) too, nothing change.

@Mulderua
Copy link
Contributor

Hi @srbarba , thank you for your video.
Internal ticket MAGETWO-54633 was created.

@NadiyaS NadiyaS added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed Progress: needs update labels Jun 22, 2016
@vkorotun vkorotun removed the CS label Aug 4, 2016
@ghost
Copy link

ghost commented Aug 19, 2016

Hi,

Just to let you know I'm also getting this similar when you try and click on "send email" for an invoiced order.

I'm also using magento version 2.0.7

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder::getItemPrice() must be an instance of Magento\Sales\Model\Order\Item, instance of Magento\Sales\Model\Order\Invoice\Item given, called in /Users/chris/Sites/magento_test/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml on line 34 and defined in /Users/chris/Sites/magento_test/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php:97 Stack trace: #0 /Users/chris/Sites/magento_test/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml(34): Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder->getItemPrice(Object(Magento\Sales\Model\Order\Invoice\Item)) #1 /Users/chris/Sites/magento_test/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/Users/chris...') #2 /Users/chris/Sites/magento_test/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\Vi in /Users/chris/Sites/magento_test/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php on line 97

Thanks

@ghost
Copy link

ghost commented Jan 9, 2017

Hi,

Btw - The problem is the Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder::getItemPrice() method.

public function getItemPrice(OrderItem $item)
{
    $block = $this->getLayout()->getBlock('item_price');
    $block->setItem($item);
    return $block->toHtml();
}

If you take off the Type hint OrderItem $item for the argument and just have:

public function getItemPrice()
{
    $block = $this->getLayout()->getBlock('item_price');
    $block->setItem($item);
    return $block->toHtml();
}

it works fine

@ghost
Copy link

ghost commented Jan 9, 2017

Also this is in magento 2.1.12 as well

@NadiyaS NadiyaS removed their assignment Jan 10, 2017
@gabriel-au
Copy link

Hi everyone.

Any news about this error?

Cheers.

@sshymko
Copy link

sshymko commented Mar 22, 2017

Experiencing the issue on 2.1.4.
Trying out the type hinting workaround by @ghost.

@sshymko
Copy link

sshymko commented Mar 23, 2017

It is tricky to implement a workaround as a custom module, because the signature of the method \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder::getItemPrice() cannot be overridden by a descendant due to type incompatibility of order item and invoice item.

Looking forward to the fix in core.

@SanderJP
Copy link

SanderJP commented May 9, 2017

@Mulderua please provide an update about this issue?
We cannot release our clients Magento 2 webshop because customers see a broken white page after they paid and return from the PSP !! And there is no workaround except changing core code, which means I need to do this manually every single time my CI pipeline has run..

It's almost been a year since this issue was posted..

@c0rewell
Copy link

c0rewell commented May 26, 2017

just create preference for \Magento\GroupedProduct\Block\Order\Email\Items\Order\Grouped

and extend your block from \Magento\Framework\View\Element\Template. This way you can change signature of buggy getItemPrice($item) method. Don't forget to copy the rest methods from \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder

@abolivar
Copy link

Same error 2.1.5

  • Clean install
  • Create grouped product
  • Place in order
  • Invoice order
    -Resend email

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder::getItemPrice() must be an instance of Magento\Sales\Model\Order\Item, instance of Magento\Sales\Model\Order\Invoice\Item given, called in /var/www/html/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml on line 34 and defined in /var/www/html/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php:97 Stack trace: #0 /var/www/html/vendor/magento/module-sales/view/frontend/templates/email/items/invoice/default.phtml(34): Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder->getItemPrice(Object(Magento\Sales\Model\Order\Invoice\Item)) #1 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/html/v...') #2 /var/www/html/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\GroupedProduct\Block\Order\Email\Items\Order\Grouped), '/var/www/html/v...', Array) # in /var/www/html/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php on line 97

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
jaykobi pushed a commit to jaykobi/magento2 that referenced this issue Sep 25, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Sep 27, 2017
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Sep 28, 2017

@srbarba, thank you for your report.
We've created internal ticket(s) MAGETWO-54633 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 28, 2017
okorshenko pushed a commit that referenced this issue Oct 11, 2017
…ouped Products #11297

 - Merge Pull Request #11297 from michielgerritsen/magento2:5105_email_invoice
 - Merged commits:
   1. 60d6628
@okorshenko
Copy link
Contributor

Hi @srbarba the issue has been fixed in 2.2-develop branch and will be available in 2.2.1 release soon

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Oct 11, 2017
@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-81340

@versdivers
Copy link

This is still an error in Magento 2.2.1

@okorshenko
Copy link
Contributor

The fix was delivered in 2.2.2 60d6628

@magento-team
Copy link
Contributor

Hi @srbarba. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1282 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 25, 2018
@arnoudhgz
Copy link
Contributor

The error appears again, and it seemed like that the change to fix the issue has been reverted in 62fed32

@arnoudhgz arnoudhgz reopened this Nov 13, 2019
@ghost ghost unassigned michielgerritsen Nov 13, 2019
@ghost ghost removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Nov 13, 2019
@arnoudhgz arnoudhgz added Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release and removed Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Nov 13, 2019
@engcom-Echo engcom-Echo self-assigned this Nov 14, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 14, 2019

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Echo
Copy link
Contributor

Hello @arnoudhgz

Thank you for your report and collaboration!
We are not able to reproduce this issue on the 2.3-develop branch by provided steps.

Testing scenario:

Preconditions:
Grouped Product which consists of two simple products has been created and assigned to a category

Steps to reproduce:

  1. Add Grouped Product to cart.

  2. Place an order with the grouped product.

  3. Go to admin.

  4. Go to Sales → Orders and open the current order with the grouped product.

  5. Go to Invoice and select the "Email Copy of Invoice" checkbox.
    Screenshot from 2019-11-14 17-54-47

  6. Press "Submit Invoice".

  7. Check e-mail

Result:
The Invoice has been created successfully. No errors. An Email is came.
Screenshot from 2019-11-14 17-57-26
Screenshot from 2019-11-14 18-02-14
Screenshot from 2019-11-14 18-02-31
Thank you!

@arnoudhgz
Copy link
Contributor

@engcom-Echo you are correct, the issue I found was about the credit memos (the file is almost similar). I will try it out again for credit memos and create a new issue.

@arnoudhgz arnoudhgz added Fixed in 2.3.x The issue has been fixed in 2.3 release line and removed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Progress: needs update labels Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests