How to Test Fulfillment Service Fetch Stock

Solved
Shopify Partner
2 0 0

Hello,

 

I am currently working on a project to get our system integrated with Shopify. I'm at the beginning phases of the implementation. I'm only testing the API through Postman at the moment and am working on defining work for our team to integrate Shopify into our system. So far I have an app, a test store that has our app installed and a fulfillment service with that store that is set to manage inventory for all existing products. Now I need to know how to test inventory management through the fetch_stock call to our system. I believe creating a new product triggers a fetch_stock call to our system for that SKU, but that doesn't work for us as a test method because we don't normally have inventory before creating the product in our system. 

 

Is there a way to manually trigger the fetch_stock call to our fulfillment service, either for an individual SKU or all products? Also, are there logs to help us verify when a fetch_stock attempt was made and whether it succeeded or failed?

 

Thanks,

Glen Elder

Sr. Software Engineer

Best Inc. 

0 Likes
Highlighted

Success.

Shopify Staff
Shopify Staff
152 19 15

Hey @GElder185,

 

The only way to manually trigger a fetch_stock is attach your fulfillment service to a product, by either creating a new product or updating the fulfillment service on an existing one.

 

When I've needed to test, I just toggle the fulfillment service for a product between `manual` and the fulfillment service I'm testing. This simulates the same behaviour as fetch_stock, since the inventory quantity stays intact when you toggle.

 

For example, if a product managed by your fulfillment service is currently showing 10 units in Shopify, when you toggle the fulfillment service to manual the product will still have 10 units. When you toggle back to your fulfillment service, this triggers a fetch_stock, and inventory will be updated based on the response.

 

Otherwise, the fetch_stock call occurs every hour. On all stores I've looked at recently, the call happens between :20 and :30 minutes on the hour, though this could technically happen at anytime.

 

With regards to logs, there isn't anything public facing that you can look at. But if you're sure your network is configured correctly, you can use a tool like NGROK which logs out all requests to your endpoint. Using NGROK, you can see all incoming fetch_stock calls along with the status code your app responded with. 

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
Shopify Partner
2 0 0

That is actually very helpful. I hadn't thought to toggle the fulfillment service to trigger the fetch. This will definitely speed up testing as we couldn't realistically wait around for an hour every time a test failed to test our changes.

 

Regarding logs, we already have logging implemented on our end that logs all incoming and outgoing traffic. This is probably good enough for most cases. I just would have liked for the store owner that we're integrating with to have some way of knowing that these inventory updates are active and working as they won't have access to logs on our end. This much lower priority though so I think this is good enough for us to move forward. Thanks!

0 Likes