Jump to content

How to make a call from prestashop to my own API?


jotaeme

Recommended Posts

Hi everyone!

 

I'm working in this issue for a few days now, and I'm not sure how I can solve it. I want to connect prestashop with my erp so every time there is a sign up or an order is made prestashop calls my API and I can save the prestashops data in my erp database. 

 

Then, from my api I'd make another call to the prestashop webservice and I'd get all the data that is needed. 

 

Is it a good solution? Does anyone know how it can be done?  

 

Thanks!

Link to comment
Share on other sites

Do you know how to program in PHP?

 

I do.

 

What I want to do is to save the prestashop data (new customers and orders mostly) in my erp database. So I thought it would be a good idea to make a simple restful api where prestashop calls everytime it is needed. How should I do that? Any ideas?

 

Thanks.

Link to comment
Share on other sites

Yes.  Prestashop uses a "hook" design.  This means at predefined stages of the workflow, you can be notified about the event and then do something.

 

So you would create a module that registers 2 hooks

1) new customer.  I forget what the actual hook name is called.  But your module would listen for this 'create customer' event.  Your module function would get executed, and you can interact with your restful api.

 

2) new order.  same as above

 

just be sure to use a try/catch block in your functions, so that in the event of a remote api failure, the customer is not impacted and can continue to use the site

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...