Want to display the right products in your Wix store, exactly where your visitors need them? With Wix Velo product queries, you can retrieve products and build more dynamic shopping experiences using code.
This guide walks you through the basics of querying Wix Stores products with Velo, including how to find products that match your needs and use the results on your site. Whether you’re creating a custom product list or adding smarter filtering, you’ll have a clear starting point for making your store more flexible.
Set Up Wix Velo Product Queries
A product list is only useful when it shows the right items—and stays manageable as your catalog grows. I start by checking that the right Wix tools are available, then build a query around what the page actually needs.
Before writing a query, make sure your site has the store features and code access it depends on. This first step helps avoid chasing code errors caused by a missing setup.
Enable the Stores API
Turn on Velo Dev Mode in the Wix Editor and confirm that Wix Stores is installed on your site. The Stores APIs are then available to your code; for product queries, I use the wix-stores.v2 module in backend code where appropriate.
Keep access in mind as you choose where the query runs. If your page needs results from a backend function, expose that function as a web module and call it from the page. This gives you a clear place to manage permissions and keeps store-related logic out of the page layout.
Once the API is ready, choose a query approach that fits the page instead of fetching a large catalog by default. The method you select affects how easily you can refine results later.
Choose a Query Method
For a custom product grid, I use queryProducts() and add conditions before calling find(). For example:
const result = await products
.queryProducts()
.eq("visible", true)
.ascending("name")
.limit(12)
.find();
This pattern keeps the request focused: the example selects visible products, sorts them by name, and asks for up to 12 results. If you only need one known item, a direct product lookup is a better fit than querying the whole catalog.
With a method in place, narrow the results to match the visitor’s task. A few deliberate filters can make a product list easier to browse and faster to work with.
Filter and Sort Products
I add filters for specific needs, such as showing only a product type or a chosen category. Combine conditions carefully, and check that the field names and values match your store’s product data.
Sorting also shapes the experience. Use ascending or descending order for a useful sequence—such as alphabetical browsing or price-led comparisons—and set a limit for the number of items to display at once. For larger catalogs, load results in batches rather than requesting everything in one go.
Finally, treat query results as data that may be empty or unavailable, not as a guaranteed list. A little defensive handling makes the page feel more reliable when products change.
Handle Results and Errors
Read the returned items array and check whether it contains products before rendering a grid. When it is empty, show a helpful message or an alternate selection instead of leaving a blank space.
I also wrap asynchronous requests in try...catch so a failed request does not break the page. Log details for debugging, but show shoppers a simple message; then consider pagination or smaller limits if the catalog is large.
Build Wix Velo Product Queries
Once the basic query is working, small changes can make it much more useful to shoppers. I usually start with a clear selection rule, then shape the results around how people will browse the page.
A category page and a product detail page need different kinds of lookups. Here, I’ll narrow results by collection or ID, then cover name searches and stock-aware displays.
Query by Category or Product ID
In Wix Stores, categories are represented by collections. If you have a collection ID, use it to return products assigned to that collection rather than fetching the whole catalog.
const result = await products
.queryProducts()
.hasSome("collectionIds", [collectionId])
.eq("visible", true)
.limit(12)
.find();
For a known product, filter by its ID instead. This is handy when a page needs to feature one item without relying on its name, which may change:
const result = await products
.queryProducts()
.eq("_id", productId)
.limit(1)
.find();
Both patterns return query results, so I still check result.items before using them. If your site uses a different category setup, confirm that the collection ID matches the product data.
Visitors may arrive with a particular item in mind, or they may simply want to see what can ship now. Those needs call for a text search and a careful distinction between visibility and availability.
Search by Name or Availability
For a simple name search, use a search term from a text input and match it against the product name. Trim the input first so accidental spaces do not affect the results.
const term = $w("#searchInput").value.trim();
const result = await products
.queryProducts()
.contains("name", term)
.eq("visible", true)
.limit(12)
.find();
Visible does not always mean in stock. Inventory can be tracked differently across products and variants, so check the returned inventory information using the fields supported by your Stores API version before labeling an item “Available.” I avoid showing an out-of-stock badge based only on a product’s visibility setting.
As a catalog grows, loading every match at once can slow the page and overwhelm shoppers. A fixed page size gives you a predictable first view, with a way to request more when needed.
Limit and Paginate Results
Use limit() to control how many products appear at once. To fetch later batches, calculate an offset from the page number and apply it with skip().
const pageSize = 12;
const page = 2;
const result = await products
.queryProducts()
.eq("visible", true)
.skip((page - 1) * pageSize)
.limit(pageSize)
.find();
I keep the page size consistent and offer a clear Load more button or pagination controls. If products are added or removed between requests, offset-based pages can shift, so refresh the list when shoppers change filters.
After refining the results, connect them to the page elements shoppers can act on. A repeater works well for a product grid because it uses one layout for every returned item.
Display Products on Your Site
Set up the repeater’s item handler before assigning its data, so each product is ready to render as the list appears. For example, I bind the product name to a text element:
$w("#productRepeater").onItemReady(($item, product) => {
$item("#productName").text = product.name;
});
$w("#productRepeater").data = result.items;
Then I add the details that suit the page, such as price, image, or a link to the product page. Keep the empty state useful too: when no items match, show a short message and let visitors clear or adjust their filters. This turns Wix Velo product queries into a browseable store experience, not just a data request.
Improve and Troubleshoot Queries
A product grid can look perfect with a small catalog, then behave differently once shoppers start filtering or the store gets busier. I check performance, access, and real-world edge cases before treating a query as finished.
First, I look at how often the page requests data and how much it asks for. A few small adjustments can keep the experience responsive as the catalog grows.
Keep Queries Efficient
Request only the products needed for the current view. Keep a sensible page size, add filters before calling find(), and avoid running the same request repeatedly when a shopper changes a control. For a search box, I wait until the visitor pauses typing before sending the next request.
I also avoid making a separate query for every repeater item. Fetch the product list once, then use the returned data to populate each item. When adding pagination, use a consistent sort order so products are less likely to jump between pages.
- Use filters to narrow the catalog before displaying results.
- Load another batch only when a visitor asks for it.
- Refresh results when filters change, and ignore outdated responses if a newer search has already started.
Speed is only part of the picture; a query also needs the right access and reliable product data. I verify those basics next, especially when code runs through a backend function.
Check Permissions and Data
If a request works in one context but fails in another, check where it runs and what permissions that code has. For a backend web module, expose only the function the page needs and set its access deliberately. Do not send private credentials or unrestricted store operations to browser code.
Then compare the query with actual product records. Confirm that the field exists, its value has the expected type, and the collection ID is correct. I also distinguish a product being visible from it being available to buy; inventory and variant details may need separate checks.
Once access and fields look right, I test the situations shoppers are most likely to encounter. This helps catch problems that a successful query with a full catalog will not reveal.
Test Common Query Scenarios
I test in Preview and on the published site, since permissions and page behavior can differ. My checklist includes:
- A search with no matches, plus one with leading or trailing spaces.
- A category with few products and one with more products than a page can show.
- Hidden, out-of-stock, or variant-based products.
- A failed request, confirming the page shows a useful message rather than breaking.
During development, I log the error details and inspect the returned items; for shoppers, I keep the message simple. These checks make Wix Velo product queries easier to maintain when the catalog or page changes.
Turn Product Queries into a Better Store Experience
Wix Velo product queries give you a flexible way to shape product lists around what shoppers need, from focused category pages to searchable grids. The key is to pair the right query with thoughtful filtering, clear result handling, and a display that’s easy to browse.
Keep performance, permissions, and changing product data in mind as your store evolves, and test the edge cases—not just the perfect results. With those habits in place, you can build more responsive shopping experiences and keep improving them as your catalog grows.
0 Comments
No comments yet. Share your thoughts or questions below.