Rulian Posted June 28, 2017 Share Posted June 28, 2017 Hi, I'm working for a record dealer who currently uses Prestashop 1.6.The guy would like to sell records from its Prestashop website as usual, but also from Discogs (a records selling marketplace with a nice API).My current concern is how to update the stock on the Discogs side, each time we sell something via PrestaShop.At which point, when a PS order is considered as done, should I call the discogs API in order to decrease the discogs stock for the corresponding items ?Does any of you encountered the same kind of situation ? (updating an external reference when something is sold on PS) ?Any help appreciated,Cheers Link to comment Share on other sites More sharing options...
bellini13 Posted June 28, 2017 Share Posted June 28, 2017 For this you would likely want to create a module in Prestashop, and then implement hooks (aka events). There are probably a few different ways to implement this using hooks My first thought is to register for the "new order" hook, and then react based on the contents of the order. However there are likely hooks that would trigger based on stock changing, and this may be the better approach, since it would deal with returns/refunds etc.. 1 Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted June 29, 2017 Share Posted June 29, 2017 Hi..you need use your custom module hook with "actionOrderStatusUpdate" like the below public function install() { return parent::install() && $this->registerHook('actionOrderStatusUpdate'); } public function hookActionOrderStatusUpdate($params) { $orderstates = $params['newOrderStatus']; if($orderstates->id == "id"){ //your api call here } } Thanks 1 Link to comment Share on other sites More sharing options...
Rulian Posted June 29, 2017 Author Share Posted June 29, 2017 (edited) Thank you guys, that's exactly what I was looking for ! My PS dev skills are a little bit rusty and I forgot about the hook/event thingy. I was thinking about overriding a class/controller (but didn't know wich one to extend), but the module registering the right event looks way better. Edited June 29, 2017 by Rulian (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 29, 2017 Share Posted June 29, 2017 Just look into the existing hook positions and choose the one that makes the most sense. actionOrderStatusUpdate gets triggered whenever there is an order status change. That may or may not be the best thing for your needs. Link to comment Share on other sites More sharing options...
Scully Posted June 29, 2017 Share Posted June 29, 2017 Or directly overwrite the order controller with a new function which updates external database when needed. Then you need eigther a remote host where you can connect to a database (preferred if possible) or you write some kind of XML or other formatted data into a certain folder and the third-party system fetches data from your prestashop server. What I can say with my experience: It's not done within one or two hours. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now