I’m pretty new to Magento custom modules and just want to be pointed in the right direction to read up on things.
I’m creating a few websites that I want to have stock dynamically updated from an API (that I’m developing).
Currently I have a script that runs every day to update every product with the current stock count, and another script that gets the difference since the last update and does it (every 10minutes).
I don’t like it as there is still room for error and it just doesn’t sit right with me. What I would like is as you click on the product, it makes an API call, updates my custom field, and renders the page. I also have a custom stock status plugin so I really need it to do the call before page load. . I can write some logic on timeout to render the page anyway if there is a problem with the API.
Any pointers would be really helpful.
2
Answers
Got it working... Thanks for your help, there is still some work to do, but its calling the script at the correct time! Thankyou
Events.xml
You can use the Event/Observer feature to call the API. Try one of the following events:-