Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I'm using the Query as below.
{
products(first: 8 ,query:"title: ${productSearchTerm?.isEmpty == true ? "*" : '*$productSearchTerm' + '*'}, variants.price:>0", after: ${cursor.isEmpty ? null : '''"$cursor"'''}, , sortKey: TITLE) {
pageInfo{
hasNextPage
hasPreviousPage
}
allProducts : edges{
cursor
productDetails : node{
id
onlineStoreUrl
handle
title
description
descriptionHtml
variantsResult: variants(first:8){
allVariants: edges{
variantDetails: node{
title
availableForSale
id
presentmentPricesResult: presentmentPrices(first:1){
allPresentmentPrices: edges{
presentmentPricesDetail: node{
presentmentActualPrice: price{
amount
currencyCode
}
presentmentComparePrice: compareAtPrice{
amount
currencyCode
}
}
}
}
actualPrice: price
imageDetails: image{
originalSrc
}
weight
weightUnit
requiresShipping
}
}
}
imagesResult: images(first:6){
allImages: edges{
imageDetails: node{
originalSrc
}
}
}
priceRange{
maxVariantPrice{
amount
currencyCode
}
minVariantPrice{
amount
currencyCode
}
}
}
}
}
}
But No matter what I pass for title, I'm getting the Empty List. When Empty String is passed, I get 8 Products from Latest Arrivals Category.
Solved! Go to the solution
This is an accepted solution.
The next problem is this:
products(first: 8 ,query:"title:flutter*, variants.price:>0", after:null, sortKey: TITLE)
What are you doing with the comma after "flutter*" is that suppose to be and "AND"?
In other words: "give me the first 8 products with the title that starts with flutter AND the variant price is > 0"?
If so then try this:
products(first: 8 ,query:"title:flutter* AND price:>0", after:null, sortKey: TITLE)
For my test store I used this modified version of your Query where I know that only one variant has a title that starts with 5 and price less than 49:
{
products(first: 8 ,query:"title:5* AND price:<49", after: null, sortKey: TITLE) {
pageInfo{
hasNextPage
hasPreviousPage
}
allProducts : edges{
cursor
productDetails : node{
id
onlineStoreUrl
handle
title
description
descriptionHtml
variantsResult: variants(first:8){
edges{
variantDetails: node{
title
availableForSale
id
presentmentPricesResult: presentmentPrices(first:1){
allPresentmentPrices: edges{
presentmentPricesDetail: node{
presentmentActualPrice: price{
amount
currencyCode
}
presentmentComparePrice: compareAtPrice{
amount
currencyCode
}
}
}
}
actualPrice: price
imageDetails: image{
originalSrc
}
weight
weightUnit
requiresShipping
}
}
}
imagesResult: images(first:6){
allImages: edges{
imageDetails: node{
originalSrc
}
}
}
priceRange{
maxVariantPrice{
amount
currencyCode
}
minVariantPrice{
amount
currencyCode
}
}
}
}
}
}
Hope this helps
Cheers
Hi there... Its a simple fix. Remove the space after the colon.
from...
"title: ${pro
to
"title:${pro
The search is looking for anything that starts with a space..
To help with debugging I would also suggest not to try to have logic like you have but to perform all logic prior to passing the seach term, same with your cursor.
Cheers,
Gary
Hi,
I tried this. Still the list is coming empty.
When the search query is empty
products(first: 8 ,query:"variants.price:>0", after:null, sortKey: TITLE)
I'm getting all products sorted by Title which is as expected.
And When I enter some search query, after I made the changes you suggested, this is how it looks now
products(first: 8 ,query:"title:flutter*, variants.price:>0", after:null, sortKey: TITLE)
Still no results.
Have tried *flutter*, flutter, and also tried removing the `after` parameter when it is null.
Here flutter is full name of a product.
I don't understand what I'm missing or what I'm doing wrong here.
This is an accepted solution.
The next problem is this:
products(first: 8 ,query:"title:flutter*, variants.price:>0", after:null, sortKey: TITLE)
What are you doing with the comma after "flutter*" is that suppose to be and "AND"?
In other words: "give me the first 8 products with the title that starts with flutter AND the variant price is > 0"?
If so then try this:
products(first: 8 ,query:"title:flutter* AND price:>0", after:null, sortKey: TITLE)
For my test store I used this modified version of your Query where I know that only one variant has a title that starts with 5 and price less than 49:
{
products(first: 8 ,query:"title:5* AND price:<49", after: null, sortKey: TITLE) {
pageInfo{
hasNextPage
hasPreviousPage
}
allProducts : edges{
cursor
productDetails : node{
id
onlineStoreUrl
handle
title
description
descriptionHtml
variantsResult: variants(first:8){
edges{
variantDetails: node{
title
availableForSale
id
presentmentPricesResult: presentmentPrices(first:1){
allPresentmentPrices: edges{
presentmentPricesDetail: node{
presentmentActualPrice: price{
amount
currencyCode
}
presentmentComparePrice: compareAtPrice{
amount
currencyCode
}
}
}
}
actualPrice: price
imageDetails: image{
originalSrc
}
weight
weightUnit
requiresShipping
}
}
}
imagesResult: images(first:6){
allImages: edges{
imageDetails: node{
originalSrc
}
}
}
priceRange{
maxVariantPrice{
amount
currencyCode
}
minVariantPrice{
amount
currencyCode
}
}
}
}
}
}
Hope this helps
Cheers
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By