GithubHelp home page GithubHelp logo

mage-os / mageos-common-async-events Goto Github PK

View Code? Open in Web Editor NEW
6.0 11.0 3.0 65 KB

This module implements the most common events like order creation or customer change for the Mage-OS Asynchronous Events module.

License: MIT License

PHP 99.14% Shell 0.86%
adobecommerce ecommerce mage-os magento magento2

mageos-common-async-events's Introduction

Mage-OS Common Asynchronous Events

Send REST requests to external endpoints asynchronously. This module implements the most common events like order creation and customer change.

This module uses the Mage-OS Asynchronous Events module as a basis.

Installation

composer require mage-os/mageos-common-async-events

If you run into an error like "Could not find a version of package mage-os/mageos-common-async-events matching your minimum-stability (stable).", run this command instead:

composer require mage-os/mageos-common-async-events @dev

Enable and install the module:

bin/magento setup:upgrade

Usage

You can now use the following events without having to implement them yourself.

Event identifier Description Remarks
customer.created Whenever a customer is created
customer.updated Whenever a customer is saved, except it's new
customer.address.created Whenever a customer address is created
customer.address.updated Whenever a customer address is saved, except it's new
sales.order.created When a new order is created
sales.order.updated When the state of an existing order is changed
sales.order.paid When an order is fully paid
sales.order.shipped When an order is fully shipped
sales.order.holded When an order is set "on hold"
sales.order.unholded When an order is released from "on hold"
sales.order.cancelled When an order is cancelled
sales.shipment.created When a new shipment is created
sales.invoice.created When a new invoice is created
sales.invoice.paid When an invoice is paid
sales.creditmemo.created When a new creditmemo is created

You can use these events by

mageos-common-async-events's People

Contributors

avstudnitz avatar gowrizrh avatar mage-os-ci avatar vinai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mageos-common-async-events's Issues

Use sales_order_save_commit_after event

Hi

I am using the mageos-common-async-events module to dispatch a webhook call when a new order is placed is.
The event sales_order_save_after fires, but it fails when the consumer is trying to fetch the order by order ID. Despite having the correct order ID in the observer, when the consumer is trying to fetch the order, it returns an error: The entity that was requested doesn't exist. Verify the entity and try again.

This is apparently because all *_save_after observers allow for modification of the entity in question before MySQL commits it to the database, where as *_save_commit_after observers waits until after the MySQL transaction has been committed.
Since we don't want to modify the order, and instead we want to wait until after it's been saved completely in the DB, it would be better to use sales_order_save_commit_after instead of order_save_after.

What do you think

Customer registry caching

The CustomerRepository uses a CustomerRegistry which will cache entities on load. If the updates happen in a
different thread, there is a possibility that stale data is returned.
However, we still want to use the repository instead of using the resource model to preserve modifications
added by plugins.

There are two solutions to this

  • Instead of publishing the ID to the queue, publish it as serialized JSON and create a new service interface (StaticServiceInterface etc) with a get which will do nothing except take in the input and return it as is (unserialize maybe required)
  • Recreate the customer repository's get just for the sake of publishing but do not use the internal cache and always load from DB. I can provide an example of this if you'd like. However with this approach, you might lose custom plugins that modify data on it.

Please see
aligent/magento2-default-async-events#1 (comment)

https://github.com/aligent/magento2-default-async-events/blob/54c2943b0f08a31e56527a5c21e90f259c7d9db0/Model/AsyncCustomerManagement.php#L39

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.