FROM CACHE - en_header

How to prevent redownloading the same orders?

Solved
André_Veltstra
Excursionist
35 0 6

I programmed an application that periodically queries the Admin Orders REST API for new orders. In the request I provide several query parameters. But what I don't see in Shopify's API documentation is a way to acknowledge that the application downloaded an order, and subsequently filter it out of the next download response.

 

Currently the application remembers the highest order id it encountered. It passes that back into the orders request using the since_id query parameter. This works most of the time. But it also puts the burden on my application. I am looking to put that burden on Shopify.

 

The orders APIs of several other e-commerce facilitators allow me to acknowledge the fact that I downloaded an order. The next request then can filter out any acknowledged orders before sending me the response.

 

Does Shopify offer something similar?

I architect and optimize software, focusing on data integration. Currently I do this for a fashion design and manufacturing company located in midtown Manhattan, NYC.
Accepted Solution (1)

Accepted Solutions
HunkyBill
Shopify Expert
4817 60 572

This is an accepted solution.

As I said... make a new table in your DB called orders. Store the ID of an order in it. Make the column Unique... so you cannot duplicate an entry. 

 

When you process an order, look for the ID in the table. If it is there, IGNORE the current order. If not, process the order, and when you are done, add the ID to the table. That helps ensure when you mess up and get some of the same orders, you do not process them twice. Really simple. Takes but a minute!

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

View solution in original post

Replies 5 (5)
HunkyBill
Shopify Expert
4817 60 572

If you examine the parameters you are allowed to provide to the endpoint when you make your request, you will notice the solution which is the since_id. You provide that in your request and the response will then only contain orders since that ID. Naturally, you can always set the value of the since ID in your App to represent the last order downloaded.

 

Since that is apparently not good enough for you, the simplest trick in the books is to make a table that has a unique index on it. For every order you successfully process, add the id to the index. Since it is unique, the SQL will just ignore dupes. So if you query that table with an ID and it returns NULL, you're good to go....

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
André_Veltstra
Excursionist
35 0 6
Hi HunkyBill,

Thank you for your reply.

I'm already using the since_id query parameter. I thought I had mentioned that in my opening post. My description will not have been clear enough. Please accept my apologies.

When my application uses this parameter, sometimes it makes a mistake and provides the wrong value. I have encountered 1 edge case that caused this behavior over the weekend. That problem got fixed. Its root cause and solution lie outside the focus of this discussion topic.

The result of that problem, is that my applications wind up downloading the same orders multiple times, causing duplication.

What I'm looking for is an additional way to prevent that, on top of the since_id query parameter and other order query parameters my application uses: fulfillment_status, financial_status, status, and confirmed.

Thank you!
I architect and optimize software, focusing on data integration. Currently I do this for a fashion design and manufacturing company located in midtown Manhattan, NYC.
HunkyBill
Shopify Expert
4817 60 572

This is an accepted solution.

As I said... make a new table in your DB called orders. Store the ID of an order in it. Make the column Unique... so you cannot duplicate an entry. 

 

When you process an order, look for the ID in the table. If it is there, IGNORE the current order. If not, process the order, and when you are done, add the ID to the table. That helps ensure when you mess up and get some of the same orders, you do not process them twice. Really simple. Takes but a minute!

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
André_Veltstra
Excursionist
35 0 6

Hi HunkyBill!

 

I have the architecture in place to implement your suggestion. Yes, it is a quick and simple solution.

 

I was hoping for something Shopify could provide. But I guess it's left to each and every single programmer out here to implement their own.

 

Thank you for your assistance!

I architect and optimize software, focusing on data integration. Currently I do this for a fashion design and manufacturing company located in midtown Manhattan, NYC.
oredge
Shopify Partner
1 0 0

As Veldstra, I feel this is a functionality the Shopify API should provide.

I will implement the extra table in my application solution but our software connects to multiple different solutions. Not sure creating extra tables is a clean/optimal solution in this case.