Reputation: 3147
I have built a django app that is the primary store for my products. From this, I publish products to my Shopify Store. Now my django app knows first when my product goes out of stock.
Question: What options do I have to search for products using the Python API? Can I search by Title, Variant SKU?
Is storing the generated ID while publish the only means to get a handle on the product later?
I want to do this - so that I can mark the products Out Of stock, in a batch process, for example.
Upvotes: 1
Views: 5273
Reputation: 928
YOu can use the official shopify python API to find a product with id:
shopify.Product.exists(product.id) # => True
product = shopify.Product.find(292082188312)
For searching products with the product title, you can use GraphQL API
Upvotes: 1
Reputation: 1522
Storing the product's id is the simplest way to get a handle on the product later.
However, the product API shows that you can filter products by vendor, handle, product_type, collection_id, published_status, updated_at, created_at or published_at.
The Using the shopify python API page shows how you can use these filters through keyword arguments to the find class method, e.g. shopify.Product.find(collection_id=841564295)
to list products in a specific collection.
Upvotes: 2