cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to implement external webhook for add to wishlist

Best way to implement external webhook for add to wishlist

Hi, 

 

My use case is to trigger some external actions whenever there is a add to wishlist for any product by any user. What's the best way to do this? I can think of the following options

 

a) Build a module which catches the add to wishlist event and curls an external URL, which can then asynchronously trigger the actions. 

 

b) Build a cron which runs every few minutes and queries the DB for any new wishlist items and then invokes external URL

 

c) Build an admin REST API which returns all wishlist items sorted by descending time. A tool like Zapier polls this API periodically and triggers actions for any new items found.

 

Are there any other ways to achieve this? I am wondering what the pros and cons of each of these approach is and what do you think is the best option? For example, for a) If this curl fails, will it cancel the user action? Is the error handled gracefully?

 

1 REPLY

Re: Best way to implement external webhook for add to wishlist

@mohitz85 I suggest you use event observer to track the add to wishlist action that's the best way.

 

Come to your second option cron; Well for that you need to set time period and should occupy unnecessary load on server (like, not every hour people do add to wishlist, so good to perform when it do). Plus, you need to write additional code to fetch the products and if (configurable, bundle, custom options) then those options.  REST API is also good option but still you need to write code.

 

Regards to what if fail in calling cURL. in such cases store it into custom DB table and run CRON (obviously, possibility of fail very low)

 

Cheers

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.