magento / magento/inventory

creditmemo_created event registered twice if creditmemo mail is sent async

Open
#3,304 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### Preconditions (*)
1. Setup order/creditmemo mail sending in Magento.
2. Enable async mail sending.

### Steps to reproduce (*)
1. Place and invoice order.
2. Create creditmemo based on invoice, return items to stock and send copy of creditmemo as email to customer.
3. Order is now closed and `creditmemo_created` event is saved in inventory_reservation table.
4. Run `sales_send_order_creditmemo_emails` cronjob
5. Another `creditmemo_created` event is saved in inventory_reservation table.

### Expected result (*)
1. `creditmemo_created` event is saved only once.

### Actual result (*)
1. `creditmemo_created` event is saved twice.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the flow with async mail enabled, following creditmemo creation and the sales_send_order_creditmemo_emails cronjob. Compare when creditmemo_created is persisted in inventory_reservation before and after the cronjob; done means the event is saved only once.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.