Hi @Quique-Shopify I’ve replicated your exact code example from the forum, and it returns 0 products in my development environment. However, single-word queries DO work.
import { useEffect } from 'react';
import { useProductSearch, ProductCard, List } from '@shopify/shop-minis-react';
export function TestApiPage() {
// TEST 1: Your exact example from the forum
const { products: shopifyExactProducts, loading: shopifyExactLoading } = useProductSearch({
query: "fitness gear",
first: 10,
filters: {
gender: "FEMALE",
available: true,
price: {
min: 0,
max: 25,
},
},
sortBy: 'RELEVANCE',
});
// TEST 2: Slightly different multi-word query
const { products: test2Products, loading: test2Loading } = useProductSearch({
query: "beauty products women",
first: 10,
filters: {
gender: "FEMALE",
available: true,
price: {
min: 0,
max: 25,
},
},
sortBy: 'RELEVANCE',
});
// TEST 3: Same query as TEST 1 but with larger result set
const { products: test3Products, loading: test3Loading } = useProductSearch({
query: "fitness gear",
first: 200,
filters: {
gender: "FEMALE",
available: true,
price: {
min: 0,
max: 25,
},
},
sortBy: 'RELEVANCE',
});
// TEST 4: Single-word query
const { products: test4Products, loading: test4Loading } = useProductSearch({
query: "beauty",
first: 10,
filters: {
gender: "FEMALE",
available: true,
price: {
min: 0,
max: 25,
},
},
sortBy: 'RELEVANCE',
});
// Log all results
useEffect(() => {
if (!shopifyExactLoading) {
console.log('SHOPIFY EXACT EXAMPLE:', {
query: 'fitness gear',
products: shopifyExactProducts,
count: shopifyExactProducts?.length || 0,
titles: shopifyExactProducts?.map(p => p.title) || []
});
}
}, [shopifyExactProducts, shopifyExactLoading]);
useEffect(() => {
if (!test2Loading) {
console.log('TEST 2 (beauty products women):', {
query: 'beauty products women',
products: test2Products,
count: test2Products?.length || 0,
titles: test2Products?.map(p => p.title) || []
});
}
}, [test2Products, test2Loading]);
useEffect(() => {
if (!test3Loading) {
console.log('TEST 3 (fitness gear, first: 200):', {
query: 'fitness gear',
products: test3Products,
count: test3Products?.length || 0,
titles: test3Products?.map(p => p.title) || []
});
}
}, [test3Products, test3Loading]);
useEffect(() => {
if (!test4Loading) {
console.log('TEST 4 (beauty, single word):', {
query: 'beauty',
products: test4Products,
count: test4Products?.length || 0,
titles: test4Products?.map(p => p.title) || []
});
}
}, [test4Products, test4Loading]);
const allLoading = shopifyExactLoading || test2Loading || test3Loading || test4Loading;
if (allLoading) {
return <div>Loading tests...</div>;
}
// Render using your List component pattern
const shopifyProductRows = shopifyExactProducts
? Array.from({ length: Math.ceil(shopifyExactProducts.length / 2) }, (_, i) =>
shopifyExactProducts.slice(i * 2, i * 2 + 2)
)
: [];
return (
<div className="p-6">
<h1 className="text-2xl font-bold mb-4">API Test Results</h1>
<div className="space-y-6">
{/* Your exact example */}
<div className="border p-4 rounded">
<h2 className="font-bold mb-2">Shopify's Exact Example: "fitness gear"</h2>
<p>Products returned: {shopifyExactProducts?.length || 0}</p>
{shopifyExactProducts && shopifyExactProducts.length > 0 ? (
<List
items={shopifyProductRows}
height={400}
showScrollbar={true}
renderItem={(productRow) => (
<div className="grid grid-cols-2 gap-4 p-4">
{productRow.map((product) => (
<ProductCard key={product.id} product={product} />
))}
</div>
)}
/>
) : (
<p className="text-red-600">No products returned</p>
)}
</div>
{/* Other test results */}
<div className="border p-4 rounded">
<h2 className="font-bold mb-2">TEST 2: "beauty products women"</h2>
<p>Products returned: {test2Products?.length || 0}</p>
</div>
<div className="border p-4 rounded">
<h2 className="font-bold mb-2">TEST 3: "fitness gear" (first: 200)</h2>
<p>Products returned: {test3Products?.length || 0}</p>
</div>
<div className="border p-4 rounded">
<h2 className="font-bold mb-2">TEST 4: "beauty" (single word)</h2>
<p className="text-green-600">Products returned: {test4Products?.length || 0}</p>
{test4Products && (
<div className="mt-2">
<p className="text-sm">Sample titles:</p>
<ul className="list-disc pl-5 text-xs">
{test4Products.slice(0, 5).map(p => (
<li key={p.id}>{p.title}</li>
))}
</ul>
</div>
)}
</div>
</div>
</div>
);
}
Summary of Results
I tested 4 different query patterns using your exact code structure: (I am using iOS simulator not chrome or safari)
-
Your Exact Example: query “fitness gear” with first: 10 → Returns 0 products
-
TEST 2: query “beauty products women” with first: 10 → Returns 0 products
-
TEST 3: query “fitness gear” with first: 200 → Returns 0 products
-
TEST 4: query “beauty” with first: 10 → Returns 10 products (SUCCESS)
The only difference between the tests is the query text. Single-word queries work, but multi-word queries (including your exact example) return 0 products.
Questions
-
Is this expected behavior in the development environment? Your example code returns 0 products for me.
-
Should only single-word queries work in dev? Or is something wrong with my setup?
-
Will multi-word queries work in production? We can’t test our app properly without knowing if this is a dev-only limitation.