Product delete webook / reconciliation

HelpfulPerson
Shopify Partner
16 1 8

Hi all,

We are hoping to keep our app in sync with the merchants product catalog.

 

We'll use a webhook notify us when a product is deleted from the catalog, but also want an alternative process to reconcile products in the catalog if there should be a comm error or the webhook is missed.

 

Understand that when a merchant deletes a product it is hard deleted.

 

Can anyone recommend a bullet proof way to validate and reconcile the product catalog at any point in time?

 

Thanks in advance.

 

Kind regards,

 

Anna

Replies 3 (3)

Zameer
Shopify Staff
297 31 90

Hey Anna,

 

The only implementation that comes to mind for such a reconciliation would be to poll the products endpoint to retrieve all active ids. You can then compare that with what you have stored on your servers to determine which products have been deleted.

 

The easiest way to retrieve all products would be to use the `since_id` parameter for pagination. Your first call would be of the form:

GET /admin/products.json?since_id=1&limit=250

You would then take the largest product id returned in that request and pass it in as the `since_id` parameter of the subsequent call until you have retrieved all products. Therefore, any products which you have stored locally which weren't returned during the API calls must be deleted.

To learn more visit the Shopify Help Center or the Community Blog.

HelpfulPerson
Shopify Partner
16 1 8
Hi,

Thanks for the reply and the suggested solution.

Isn’t there a risk that if not all the products are returned for some reason, like a comm error or other, then we might accidentally delete products which are actually still active?


Zameer
Shopify Staff
297 31 90

Hey Anna,

 

As long as the API call is successful (ie: 200 is returned), then there should never be a case where an active product is not included in the list when you're using the `since_id` parameter.

 

There are instances when products could be skipped when `page` is used for pagination, but for that reason, among other performance issues, we don't recommend using it.

To learn more visit the Shopify Help Center or the Community Blog.