0

I want to take data from Magento 2 DB to another custom MySQL database. What are the possible solutions?

Should I use Magento provided APIs? The issue I see in this approach is when and at what time should I call the API to sync data? If I call it constantly it will put the load on my Magento DB and server.

If I use the API to take data first time then how will I know that there is some update in already synced data? How would I do that then?

1 Answer 1

1

There are multiple possible ways for you to achieve the sync process.

Process 1

  • Call the Magento API's from your external application to collect one time data with pagination, in-order to handle gateway timeout.
  • Write Event observer in Magento to listen any changes for this data and push it to your external application by calling API's of your application.

Process 2

  • Create a custom table in Magento using new custom module. This table will work as a queue to be pushed in your external application.
  • Write an event observer for customer & orders to listen for any changes and in observer add the record id in the newly created queue table.
  • Write a cronjob that will get triggered every 30min(or any), it will collect record id's from this queue table, get the record data using model and push it to your external application. Once pushed it will clear the entries from the queue table.
  • You can restrict max 20-30(or any) records per sync to avoid any load/timeout issue.

Hope it was helpfull. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.