简体   繁体   中英

Shopify API how to do a search query with like

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

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?

You can use direct fields to search like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM