API + Python: Missing SKU on export

New Member
2 0 0

Hello,

I'm trying to export the data from Shopify using Python and API  so I can match it with the export from store's database. 

My problem is that I found at least 1 SKU that's not exported from Shopify.

 

Python code responsible for the export is:

limit = 250

products = shopify.Product.find(limit=limit, published_status = "published")

 

No matter what I choose for published_status or remove it completely, the SKU in question does not appear.

Of course, if I go into web page and search for that SKU, I can find it.

 

Any idea how to solve this?

Thanks

Sorin  

0 Likes
Shopify Staff
Shopify Staff
220 36 38

Hey @sorin147 ,

 

In order to help investigate and search through our platform logs to determine why this SKU is not being returned, do you think you could you provide the value of the X-Request-ID header from the response of the API call triggered by the "shopify.Products.find()" call?

 

As well, if could provide your Shopify store name as well as the problematic SKU # that is not being returned, that would also be helpful for the investigation. Feel free to DM this information if you feel more comfortable keeping it private. 

 

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

0 Likes
Highlighted
New Member
2 0 0

Hello,

I found another way to retrieve the products.

json_url = "https://%s:%s@%s.myshopify.com/admin/variants.json?fields=id,product_id,sku,inventory_quantity,price,inventory_item_id&limit=%s&page=" % (api_key, password, shop_name, limit)

where limit is set to 250 and page is incremented by 1. At first, the page_count calculated like

products_count = shopify.Product.count(published_status = "all")
pages = math.ceil(products_count / limit ) 

but that proved not right since some of the products fall to another page. I've given up on this method and added a fixed number of pages (100) but with the condition to break the loop once there are no results.

 

def getMapShopify(json_url, pageCount):
    map = []
    for i in range (1, pageCount+1):
        r = requests.get("{}{}".format(json_url, i))
        data = r.json()
        if len (data['variants']) == 0: # stop the loop if the result is empty
            break
        for product in data['variants']:
            map.append(product)
    return map

This seems to be the best method I could came up with so far.

 

0 Likes