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

Product not exist fix when attempt to get an image #26877

Merged

Conversation

ilnytskyi
Copy link
Contributor

@ilnytskyi ilnytskyi commented Feb 14, 2020

Description (*)

This PR fixes an issue when async email sending is blocked because the removed product
And this error is shown

main.ERROR: Cron Job sales_send_order_invoice_emails has an error: Call to a member function getData() on null. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":73400320,"emalloc_start":37177640} [] []
main.CRITICAL: Error when running a cron job {"exception":"[object] (RuntimeException(code: 0): Error when running a cron job at /var/www/html/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php:327, Error(code: 0): Call to a member function getData() on null at /var/www/html/vendor/magento/module-catalog/Helper/Image.php:502)"} []

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Error when sending sales mails in async mode if product was removed #26876

Manual testing scenarios (*)

  1. See steps form the issue Error when sending sales mails in async mode if product was removed #26876
  2. ...

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Feb 14, 2020

Hi @ilnytskyi. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@orlangur orlangur self-assigned this Feb 15, 2020
@ghost ghost added Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels May 4, 2020
@magento-engcom-team
Copy link
Contributor

Hi @VladimirZaets, thank you for the review.
ENGCOM-7517 has been created to process this Pull Request
✳️ @VladimirZaets, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

Copy link
Contributor

@VladimirZaets VladimirZaets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ilnytskyi. Thanks for collaboration. Due to Magento Definition of Done all code must be covered by tests. Please cover your fix by automated tests or update the existing ones.

@VladimirZaets VladimirZaets added this to the 2.4.1 milestone May 13, 2020
@engcom-Echo engcom-Echo self-assigned this Jun 26, 2020
@engcom-Echo engcom-Echo added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Aug 5, 2020
@engcom-Echo
Copy link
Contributor

@magento run all tests

@engcom-Echo engcom-Echo force-pushed the async-emails-removed-product branch from 7b558cd to da38103 Compare August 7, 2020 09:44
@engcom-Echo
Copy link
Contributor

@magento run all tests

@ghost ghost removed the Progress: needs update label Aug 19, 2020
Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ilnytskyi .
Unfortunately, we are not able to reproduce this problem following by steps from the issue .

Precondition:
Have Configurable product with images;

Manual testing scenario:

  1. Set up async mails sending ( Go to Admin -> Stores -> Configuration -> Sales -> Sales Emails -> General Settings and set Asynchronous sending to "Enable");
  2. Create Order -> Invoice -> Shipment;
  3. Send sales mails

Actual Result: ✔️ All 3 messages were received

Screenshot from 2020-08-21 14-20-54

  1. Remove product (along with configurable(parent) product);
  2. try to send the invoice again
    2020-08-21_14-23

Actual Result: ✔️ the message was successfully received

2020-08-21_14-24

@ilnytskyi Could you take a look? Maybe we missed something..

Thanks!

@ghost ghost dismissed lenaorobei’s stale review August 21, 2020 11:26

Pull Request state was updated. Re-review required.

@ilnytskyi
Copy link
Contributor Author

@engcom-Alfa
It was actual for 2.3.1 so maybe now somethings is different.
Please confirm that you use cron to sent an email, and the image is used in the email template.

@lenaorobei
Copy link
Contributor

@engcom-Alfa could you please confirm #26877 (comment)

@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Sep 7, 2020

Hi @ilnytskyi @lenaorobei .

We checked this PR in more detail again and we were able to reproduce this problem in the following steps:

Precondition:

Since there is no product image variable in the email templates, we have added this programmatically.

Manual testing scenario:

  1. Set up async mails sending ( Go to Admin -> Stores -> Configuration -> Sales -> Sales Emails -> General Settings and set Asynchronous sending to Enable);
  2. Create a product with an image;
  3. Go to Storefront;
  4. Add product to Cart and create order;
  5. Send sales emails;
  6. Run cron;

Actual Result: ✔️ The order confirmation email was received

Screenshot from 2020-09-07 16-21-59

  1. Remove product ;
  2. Try to resend sales email (e.g. set column email_sent to Null in relative tables);
  3. Run cron;

Actual Result: ✖️ If there are newer sales items planned to send (email_sent is null) emails will not be sent; It leads that sales async mailing stop working

2020-09-07_16-24

in var/log/cron.log this log appears

Screenshot from 2020-09-07 16-26-14

@lenaorobei Could you approve it again?

Thanks!

@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-7517 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Sep 9, 2020

✔️ QA Passed

Precondition:

Since there is no product image variable in the email templates, we have added this programmatically.

Manual testing scenario:

  1. Set up async mails sending ( Go to Admin -> Stores -> Configuration -> Sales -> Sales Emails -> General Settings and set Asynchronous sending to Enable);
  2. Create a product with an image;
  3. Go to Storefront;
  4. Add product to Cart and create order;
  5. Send sales emails;
  6. Run cron;

Actual Result: ✔️ The order confirmation email was received

Screenshot from 2020-09-07 16-21-59

  1. Remove product ;
  2. Try to resend sales email (e.g. set column email_sent to Null in relative tables);
  3. Run cron;

Before: ✖️ Emails are not sent
✖️ If there are newer sales items planned to send (email_sent is null) emails will not be sent; It leads that sales async mailing stop working

2020-09-07_16-24

in var/log/cron.log this log appears

Screenshot from 2020-09-07 16-26-14

After: ✔️ Emails are send

Screenshot from 2020-09-09 11-32-05

✔️ If there are newer sales items planned to send (email_sent is null) emails will be sent

@m2-assistant
Copy link

m2-assistant bot commented Sep 10, 2020

Hi @ilnytskyi, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Catalog Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Error when sending sales mails in async mode if product was removed
8 participants