2
votes

Hey guys I try to do some searching functions but it is not possible with shopifyAPI gem

ShopifyAPI::Product.find(:all, conditions: ["title LIKE ?", "%#search%"], params: {limit: 20, page: 1}) 

With this function I got all products.

ShopifyAPI::Product.find(:all, conditions: ["title LIKE ?", "%#search%"])

The same I got all products

ShopifyAPI::Product.search(parameters)

I found this function in this example but it is not a function anymore => ecommerce.shopify.com/c/shopify-apis-and-technology/t/ruby-shopifyapi-find-customer-by-email-215330

ShopifyAPI::Product.where({ "title LIKE ?" =>"%#{search}%" })

With this one I got all products, again

This is the shopify_api gem => help.shopify.com/api/reference/product.
This is the shopify_api => help.shopify.com/api/reference/product

2
Did you find a solution?Rubycon

2 Answers

1
votes

It doesn't look to me like the Shopify API supports this. What you're trying to do looks like ActiveRecord querying, but this gem only provides an Active Record-like syntax.

The API does support searching based on product title, so perhaps you may be able to specify a single word or two from the product name it and it will match those?

1
votes

You can use direct fields to search like:

ShopifyAPI::Product.find(:all, params: { limit: 10, 
                                         title: params[:title],               
                                         page: params[:page] })