Skip to main content

Customize search results with the renderer

The product result renderer is a JavaScript class that controls how search results are displayed.

The Zoovu Search Plugin Renderer lets you change how search results look without affecting important features like tracking, product comparison, or chat. Instead of overriding the entire template, you can adjust specific parts: SKUs, the layout, or call-to-action (CTA) buttons.

Using the renderer approach is ideal when you:

  • Need to preserve built-in tracking and interactions.
  • Want an easier way to enable extra features like chat, comparison, and recommendations.
  • Prefer not to completely override the result card template.

Adjust styling with the renderer

If you want to adjust styling (like price display or SKU position), go to Design & Publish > Advanced > Additional CSS.

Renderer

Add the following code:

.z-search-suggests__content {
display: grid;
gap: 0.5rem 1rem;
grid-template-columns: 2fr 1fr;
}
.z-search-suggests__price {
color: #c5000c;
font-family: 'gibson_semibold';
font-size: 27px;
line-height: 1.4;
}

If you need to modify how search results behave, define a custom product result renderer:

class CustomProductResultRenderer extends ProductResultRenderer {
renderDataPoints(wrapper, product) {
const dataPoints = this.getDataPoints(product);
const ul = document.createElement('ul');
ul.className = 'z-data-points';
dataPoints.forEach((dp) => {
const li = document.createElement('li');
li.innerText = `${dp.key}: ${dp.value}`;
li.className = 'z-data-points__entry';
ul.appendChild(li);
});
wrapper.appendChild(ul);
return ul;
}
renderHeader(wrapper, product) {
const header = super.renderHeader(wrapper, product);
if (product.getIdentifier() !== undefined) {
const skuNode = document.createElement('p');
skuNode.className = 'z-sku';
skuNode.innerText = `SKU: ${product.getIdentifier()}`;
header.appendChild(skuNode);
}
return header;
}
getCtas(product, _resultGroup) {
return [{
text: 'View product',
link: this.getLink(product),
primary: true,
icon: 'none'
}];
}
}

Customizing renderer methods

MethodDescriptionArgumentsReturns
renderThe main method that creates the wrapper for the search result and calls all relevant rendering functions.Search result, isHidden flag, active result group.The rendered HTML node.
createWrapperElementCreates a wrapper <li> element for the search result card.Search result, isHidden flag, active result group.The wrapper HTML node.
createResultNodeCreates the actual search result card.Search resultThe result card HTML node.
getWrapperClassListReturns a list of class names to be added to the wrapper element.-Array of class names.
getLinkReturns the link for the search result.Search resultThe search result link.
getReadableLinkReturns a readable version of the search result link for display in the UI.Search resultThe readable search result link.
getImageReturns the main image for the search result.Search resultThe main image source.
getImagesReturns all images associated with the search result.Search resultArray of image sources.
getMaxNumberOfBadgesReturns the maximum number of badges that can be displayed for a result.-Maximum number of badges.
getBadgesReturns all badges to be displayed for the result.Search resultAn array of badges, each containing value and icon properties.
getDataPointsReturns all data points for the result, such as price or availability.Search resultAn array of data points, each with key and value properties.
getVariantImagesReturns all images for product variants.Search resultAn array of variant images, each with name, image, optimizedImage, identifier (variant SKU), and link.
getCtasReturns a list of call-to-action (CTA) buttons for the result.Search result, result groupAn array of CTA definitions, each with text, link, renderAsButton, icon, clickCallback, getLink, and primary properties.
getTitleReturns the title of the search result.Search resultThe result title.
getSnippetReturns a short description (snippet) for the search result.Search resultThe result snippet.
createImagesCreates the image container, including all images, badges, and variant thumbnails.Search resultThe images wrapper HTML node.
createImageNodeCreates an image element for the result.Search result, image source, index in images array.The image HTML node.
createCarouselCreates an image carousel for navigating through multiple images.Search result, array of image sources.The navigation HTML node.
createCarouselPaginationButtonCreates a next/previous button for image navigation.Type (prev or next), label.The pagination button HTML node.
createVariantThumbnailsCreates thumbnail images for product variants.Search resultA container node for the variant thumbnails.
createBadgesCreates a container for displaying badges.Search resultThe badges wrapper HTML node.
createBadgeCreates a single badge element.Badge definition (value and icon).The badge HTML node.
createDataPointsTableCreates a table to display data points.Map of keys to data point definitions, array of all data point keys.The data points table HTML node.
createDataPointsRowsCreates table rows for data points.Array of data point definitions (key and value).An array of table row HTML nodes.
renderHeaderCreates and appends the result title section to the search result card.Result card HTML node, search resultThe header HTML node or undefined.
renderLinkCreates and appends the clickable result link to the search result card.Result card HTML node, search resultThe link HTML node or undefined.
renderSnippetCreates and appends the search snippet (short description) to the result card.Result card HTML node, search resultThe snippet HTML node or undefined.
renderCtasCreates and appends CTA buttons (e.g., "View product") to the result card.Result card HTML node, search result, result groupThe CTA wrapper HTML node or undefined.
renderCtaCreates and appends a single CTA button to the result card.CTA wrapper HTML node, search result, CTA definition (text, link, renderAsButton, icon, clickCallback, getLink, primary).The created CTA button/link HTML node.
renderDataPointsCreates and appends the data points section to the result card.Result card HTML node, search resultThe data points table HTML node or undefined.
renderContentCreates and appends all search result content (header, link, snippet, data points, etc.).List item wrapper element, search result, result groupThe rendered content node.
isLinksOpenNewTabChecks if clicking a result should open it in a new tab.Search resulttrue or false.
isHasVariantLabelChecks if variant thumbnails or a text label should be displayed.Search resulttrue (display text label) or false (display variant thumbnails).
isHasVariantImagesChecks if the result has multiple variant images.Search resulttrue (multiple variant images available) or false (single variant image).

Content result renderer

The content result renderer is used for displaying non-product pages like blog posts, articles, or videos. It works automatically and doesn’t require any extra customization methods.

Custom result renderer

The custom result renderer is used for custom search results that are set up in Result Manager > Custom Results. Like the content renderer, it works out of the box and does not include additional customization options.

Product result renderer

The product result renderer is used for displaying products in search results. Unlike the content and custom renderers, this one offers extra methods you can override to adjust how products are displayed. You can use these methods to modify pricing, stock availability, CTAs, and more.

MethodDescriptionArgumentsReturns
findDataPointRetrieves a specific data point based on its key.Search result, data point keyThe data point (an object with key and value properties) or undefined if not found.
getPriceDataPointFinds a price-related data point. If no specific key is provided, it tries to match based on the given setting.Search result, data point key, setting name ('newPrice' or 'oldPrice')The price data point or undefined if not found.
getStockDataPointRetrieves stock availability information for the result.Search resultThe stock data point or undefined if unavailable.
getRatingDataPointRetrieves the rating value for the result.Search resultThe rating data point or undefined if unavailable.
getRatingCountDataPointRetrieves the number of ratings associated with the result.Search resultThe rating count data point or undefined if unavailable.
createComparisonActionCreates a checkbox for adding the product to a comparison list.Search resultThe generated HTML checkbox node or undefined if comparison is disabled.
createZoeChatActionCreates a "Chat about this product" button.Search resultThe CTA button HTML node or undefined if Zoovu Chat is not enabled.
renderActionsAdds comparison and chat buttons to the result card.Result card HTML node, search resultThe actions wrapper HTML element or undefined if no actions are enabled.
renderPriceDisplays the product price and appends it to the result card.Wrapper HTML node, search result, modifier ('grid' or 'list'), attachItemProps flagThe price wrapper HTML element or undefined if no price is available.
renderStockDisplays stock availability and appends it to the result card.Result card HTML node, search resultThe stock information wrapper HTML element or undefined if stock data is missing.
renderRatingDisplays the product rating and appends it to the result card.Result card HTML node, search resultThe rating wrapper HTML element or undefined if no rating is available.
renderVariantsLabelDisplays a label for product variants and appends it to the result card.Result card HTML node, search resultThe variants label HTML element or undefined if no variants exist or if variant thumbnails are being used instead.

Search result

The search result object contains useful properties and methods that help control how a search result is displayed. You can use it to access product details, images, prices, and other key data when rendering the search result card.

Properties

PropertyDescription
contentGroupThe result group the search result belongs to.
suggestThe raw data of the main product or content result (excludes variants).
variantsAn array of all variant data for the result.
pinnedtrue if this result was pinned in the result manager, false otherwise.
plainThe raw data of the result, either as a single content item or an array of products.
randomIdA randomly generated ID for the result, useful for creating unique element identifiers.
isRelationtrue if the result comes from a related search, false otherwise.

Methods

MethodDescriptionArguments
getOriginalContentGroupReturns the actual result group name, ignoring "all results".-
getLinkReturns the clickable link for the result.-
getNameReturns the title of the result.-
getTypeReturns the type of result ('custom', 'HTML' for content/product, or 'YOUTUBE_VIDEO').-
getHtmlReturns the custom result's HTML markup.-
getImageReturns the main image for the result.true if optimized image is allowed, false otherwise.
getOriginalImageReturns the original, unoptimized image for the result.-
getDataPointsReturns all data points associated with the result.Content data point name (optional, used to ignore specific data points).
hasImagetrue if the result has an image, false otherwise.-
hasContenttrue if the result includes a search snippet, false otherwise.-
getContentReturns the search snippet.Content data point name (if the snippet should be taken from a specific data point).
getIdReturns the unique ID of the result.-
getGroupIdReturns the group identifier for the product.-
getIdentifierReturns the product identifier (e.g., SKU).-
getAllVariantImagesReturns all variant images. Each variant image includes name (variant name), image, optimizedImage, identifier (variant SKU), and link (variant link).-
getUniqueVariantImageCountReturns the number of unique images across all variants.-
getImagesReturns all images associated with the result, including the main product image.-
isResizedImagetrue if an optimized image version is available, false otherwise.-
getRelationTypesReturns an array of relation types available for the result.-
getColSpanReturns the number of columns a custom result should span.Layout configuration
getRandomIdReturns the randomly generated ID for this result.-

Example: Adding SKU and custom stock message

This example:

  • displays SKU under the product title
  • adds a custom stock message ("This product will never be available")
class CustomProductResultRenderer extends ProductResultRenderer {

renderHeader(wrapper, product) {
const header = super.renderHeader(wrapper, product); // keep default rendering
if (product.getIdentifier() !== undefined) { // add the identifier if available
const skuNode = document.createElement('p');
skuNode.className = 'z-sku';
skuNode.innerText = `SKU: ${product.getIdentifier()}`;
header.appendChild(skuNode);
}
return header;
}

renderStock(wrapper, product) {
const stockNode = document.createElement('span');
stockNode.className = 'z-stock';
stockNode.innerText = `${product.getName()} will never be available`;
wrapper.appendChild(stockNode);
return stockNode;
}

}

Using callbacks to override renderers

If you need to override multiple renderers (e.g. product, content, and custom result), you can use callbacks to modify them dynamically.

  • getProductResultRenderer
  • getContentResultRenderer
  • getCustomResultRenderer

Each callback receives the default renderer class as an argument and should return your custom renderer class.