Search functionality does not work due to API limitations
ApalloAltoBluck opened this issue · comments
Oliver Buckley commented
In the getAllProducts() function, there is no logic to support Shopify's pagination requirement.
As a result, the store can only search through the first 250 products.
Oliver Buckley commented
For anyone with the same issue, I added a new function to shopify JS like this --
export async function getProductsByTitle(title) {
let query = `
{
products(first:25, query: "title:${title}*") {
edges {
node {
id
handle
title
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
images(first: 1) {
edges {
node {
originalSrc
altText
width
height
}
}
}
}
}
}
}
`
return shopifyFetch({
query: query,
})
}
This doesn't scale if there are a lot of products because of API limitations, but this provides a partial solution to a more accurate search functionality. Maybe consider looking into the Bulk operations to get a real answer to this.