rmn.nish
rmn.nish

Reputation: 889

Fetch products which are available online - Shopify

I'm building a Shopify app using Rails. I want to fetch the products which are only available online from the Collections

I have the following code to fetch the products but it returns all the products even if they are not available online

ShopifyAPI::SmartCollection.find(collection_id).products

How to pass the conditions for products?

Upvotes: 0

Views: 260

Answers (1)

Vincent Rolea
Vincent Rolea

Reputation: 1663

According to the Shopify API Reference, you can pass a published_status and collection_id parameters to your Api call to retrieve published products from a specific colleciton.

Using the Ruby library it gives:

ShopifyAPI::Product.find(:all, params: { published_status: 'published', collection_id: collection_id })

Hope it helps

Upvotes: 1

Related Questions