How to Search Specifics Products by Title via API Call

Solved
Muneeb1
Shopify Partner
22 0 0

Hi,

I have a list of products and i want to update the prodcuts price via API call. 

Actually, i have a products name and i want to search products by name via API to update its price. 

I have also try to search the product by using the below call but not get the result.

Get   /admin/products/search.json?query=title:'abc'

Can anyone help me to search the products by title via API call?

thanks in advance.

 

0 Likes
Josh
Shopify Staff
Shopify Staff
1131 82 191

This is an accepted solution.

Hi Muneeb, 

Try this :

/admin/products.json?title=my_product_title

This is currently working for me.

Muneeb1
Shopify Partner
22 0 0

Hi Josh Wheeler,

I have tried it same but still not get the product information. 

/admin/products.json?title=ARC Floral Alphabets King Bed Sheet Set

As per my understanding may be my product title have sapce. May be this was issue. 

Can you please help me to fix this issue? 

thanks 

0 Likes
Josh
Shopify Staff
Shopify Staff
1131 82 191

Hi Muneeb, 

If there is a space, have you tried to use an underscore (_) in place of each space like the example I had posted above? That should work.

0 Likes
Muneeb1
Shopify Partner
22 0 0

Hi Josh Wheeler,

thanks for update.

I have tried it but i gives me array of products instead of single product. 

I want to count all the products having inventory_quantity > 0. 

Currently i can only count all the products by using below code:

--------

$products_count = shopify_call($token, $shop, "/admin/products/count.json", array(), 'GET' );
$products_count = json_decode($products_count['response'], TRUE);                     
echo "Total Products:"  . $products_count['count'];

-------

Can you please let me know how can it count all the products that having inventory_quantity > 0? 

thanks 

0 Likes
Muneeb1
Shopify Partner
22 0 0

Can anyone anwer my query?

how can count all the products that having inventory_quantity > 0 ?

thanks

0 Likes
Subhranil
Shopify Partner
15 0 10

As per updated API:

/admin/api/2020-04/products.json?title=<searchString>&limit=250&fields=id,title
0 Likes
HunkyBill
Shopify Expert
4436 41 477

Using GraphQL, you loop through your products and make sure you also page through your variants. Add up whatever has an available number > 0. Accurate! Deadly. It even tells you how much at each location. No easy way out of it. This is the way to go. Improve as you will. I cheesed out and set the locations to 20, but you can of course be more responsible there and work with the exact number of locations too.

 

{ products(first: 1) {
  pageInfo {
    hasNextPage
  }
  edges {
    node {
      ... on Product {
        id
        title
        vendor
        productType
        variants(first: 10) {
          pageInfo {hasNextPage}
          edges {
            cursor
            node {
              inventoryItem {
                inventoryLevels(first: 20) {
                  edges {
                    node {
                      available
                      location {
                        name
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
} 
}

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes