Skip to content

Fatal error on creditmemo mail grouped product #25617

Closed
@arnoudhgz

Description

@arnoudhgz

Preconditions

  1. Magento 2.3.3
  2. Production mode and development mode

Steps to reproduce (*)

  1. Install Magento 2.3.3 with sample data
  2. Add grouped product to cart (Set of Sprite Yoga Straps)
  3. Place order
  4. Login in admin section
  5. Create invoice for order
  6. Create credit memo for order
  7. In the credit memo section click 'Send Email'

Expected result (*)

  1. Mail is send
  2. No Fatal Error

Actual result (*)

  1. Mail is not send
  2. Fatal Error is thrown
    image
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\Creditmemo\Item given, 
called in /www/magento233/vendor/magento/module-sales/view/frontend/templates/email/items/creditmemo/default.phtml 
on line 32 and defined in /www/magento233/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php:99 
Stack trace: 
#0 /www/magento233/vendor/magento/module-sales/view/frontend/templates/email/items/creditmemo/default.phtml(32): Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder->getItemPrice(Object(Magento\Sales\Model\Order\Creditmemo\Item)) 
#1 /www/magento233/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/ww...') 
#2 /www/magento233/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Gro in /www/magento233/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php on line 99

When async email is enabled

report.CRITICAL: Error when running a cron job 
{"exception":
"[object] (RuntimeException(code: 0): Error when running a cron job at /www/magento233/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:330, 
TypeError(code: 0): 
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\\Creditmemo\\Item given, 
called in /www/magento233/var/view_preprocessed/pub/static/vendor/magento/module-sales/view/frontend/templates/email/items/creditmemo/default.phtml 
on line 1 at /www/magento233/vendor/magento/module-sales/Block/Order/Email/Items/Order/DefaultOrder.php:99)"} []

Bug introduced at #22265
But if you would revert this change, the mail works, but the subtotal is wrong indeed. So I think the accepted PR did some wrong fix.

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions