
Default product grids work well for simple online catalogs, but they often fall short when buyers have specific purchasing workflows. A B2B procurement manager, for instance, rarely wants to click through large lifestyle cards one by one; they want a dense, scannable table showing SKUs, live stock levels, contract pricing, and quick-order quantity boxes on a single screen.
That is where a Custom Product List Renderer in Liferay Commerce makes all the difference. Rather than forcing your storefront into a rigid, one-size-fits-all layout or modifying Liferay’s core code, a custom renderer lets you design the exact product listing experience your customers need—and switch between layouts right from the widget configuration panel.
In this guide, we will break down how Liferay Commerce’s product list rendering works in plain terms, compare it against lighter customization options like Widget Templates and Fragments, and walk through the Java and JSP building blocks step by step.
What Is a Product List Renderer in Liferay Commerce?
In Liferay Commerce, a Product List Renderer is an OSGi-based extension that controls the layout and structure of how a group of products appears on a storefront page. Whenever a buyer browses a category, runs a search, or views a curated collection inside widgets like Product Publisher, Search Results, or Compare, Liferay uses a list renderer to turn raw catalog data into a grid, table, or custom layout.
Rather than hardcoding product layouts into a site theme, Liferay packages each renderer as an independent module inside the commerce-product-content-web architecture. From a business perspective, this keeps your storefront flexible. Marketing or merchandising teams can switch between different product list layouts right from a widget configuration panel without modifying core platform files or waiting for a full theme rebuild.
This separation also helps when your catalog needs to display live operational data alongside basic product details. For example, if your storefront pulls real-time warehouse stock or customer-specific contract pricing through Liferay Integration Services, a custom list renderer gives your team full control over how that data is organized and presented on the listing page.
List Renderer vs. Entry Renderer vs. Content Renderer
Developers new to Liferay Commerce often confuse the three rendering interfaces because their names sound similar. While they work together on the storefront, each one owns a different part of the page:
| Feature | Product List Renderer (CPContentListRenderer) | Product List Entry Renderer (CPContentListEntryRenderer) | Product Content Renderer (CPContentRenderer) |
| Primary Role | Controls the outer container and overall layout of the product collection. | Controls the layout of each individual product item inside a list. | Controls the full product view on single-product pages. |
| Where It Runs | Product Publisher, Search Results, and Compare widgets. | Inside a CPContentListRenderer loop for every item returned. | Product Details widget (single product display). |
| What It Decides | Whether products render as a multi-column card grid, a dense B2B table, or a horizontal slider. | Which fields appear on each card or row (image, SKU, price, stock label, quick-add button). | How product types (Simple, Grouped, Virtual) present galleries, options, and specs. |
| Technical Layer | OSGi service registered in the list renderer registry. | OSGi service paired with a list renderer or JSP entry template. | OSGi service scoped by product type (e.g., SimpleCPContentRenderer). |
| Best Used When | You want to change the structure of the entire product listing (such as grid to B2B order table). | You want to keep the grid or list layout, but change what appears inside each product card. | You want to customize how a specific product type looks on its detail page. |
By keeping CPContentListRenderer separate from CPContentListEntryRenderer and CPContentRenderer, Liferay lets you redesign your catalog browsing experience without breaking your existing product detail pages.
How to Build a Custom Product List Renderer in Liferay Commerce
Implementing a Custom Product List Renderer in Liferay Commerce follows Liferay's standard OSGi module pattern. You create a dedicated module containing a Java component class, a bnd.bnd descriptor so Liferay can locate your web resources, a JSP template for the HTML markup, and a Language.properties file for the UI label.
Below is the step-by-step technical implementation.
Step 1: Configure bnd.bnd for the Module
Before writing Java code, your OSGi module needs a Web-ContextPath in its bnd.bnd file. Without this header, Liferay will not generate a ServletContext for your bundle, and your Java class will fail to locate the JSP template at runtime.
Bundle-Name: Custom Product List Renderer
Bundle-SymbolicName: com.acme.commerce.list.renderer.web
Bundle-Version: 1.0.0
Web-ContextPath: /custom-list-renderer-web
Make sure the Bundle-SymbolicName here matches the osgi.web.symbolicname target you reference in your Java class in the next step.
Step 2: Register the OSGi Component in Java
Next, create a Java class that implements CPContentListRenderer and annotate it with @Component. This registers your renderer in Liferay Commerce's renderer registry so widgets like Product Publisher and Search Results can discover it.
package com.acme.commerce.list.renderer.web.internal.renderer;
import com.liferay.commerce.product.content.render.list.CPContentListRenderer;
import com.liferay.frontend.taglib.servlet.taglib.util.JSPRenderer;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@Component(
property = {
"commerce.product.content.list.renderer.key=custom-b2b-table",
"commerce.product.content.list.renderer.order=100",
"commerce.product.content.list.renderer.portlet.name=com_liferay_commerce_product_content_search_web_internal_portlet_CPSearchResultsPortlet"
},
service = CPContentListRenderer.class
)
public class CustomB2BListRenderer implements CPContentListRenderer {
@Override
public String getKey() {
return "custom-b2b-table";
}
@Override
public String getLabel(Locale locale) {
ResourceBundle resourceBundle = ResourceBundleUtil.getBundle(
"content.Language", locale, getClass());
return LanguageUtil.get(
resourceBundle, "custom-b2b-table-list-renderer");
}
@Override
public void render(
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws Exception {
_jspRenderer.renderJSP(
_servletContext, httpServletRequest, httpServletResponse,
"/view.jsp");
}
@Reference
private JSPRenderer _jspRenderer;
@Reference(
target = "(osgi.web.symbolicname=com.acme.commerce.list.renderer.web)"
)
private ServletContext _servletContext;
} Here is what each part of the class does:
- Unique key and getKey(): Identifies your renderer inside Liferay's registry. Always use a distinct key unless you intentionally want to override a built-in Liferay renderer.
- order property: Controls the position of your renderer in the widget configuration dropdown (ascending integer order).
- portlet.name property: Scopes which Commerce widget (such as Search Results or Product Publisher) can use this list renderer.
- getLabel(Locale locale): Pulls a localized display name from Language.properties so administrators see a clean label in the UI.
- render(...) and JSPRenderer: Hands off rendering to /view.jsp using the module's own ServletContext.
Step 3: Build the Custom List View in view.jsp
Place your view.jsp file under src/main/resources/META-INF/resources/view.jsp. Inside the JSP, use Liferay's CPContentHelper and CPDataSourceResult objects from the request to iterate over the returned CPCatalogEntry items and extract SKU, pricing, and stock details.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<%@ page import="com.liferay.commerce.product.catalog.CPCatalogEntry" %>
<%@ page import="com.liferay.commerce.product.catalog.CPSku" %>
<%@ page import="com.liferay.commerce.product.content.constants.CPContentWebKeys" %>
<%@ page import="com.liferay.commerce.product.content.helper.CPContentHelper" %>
<%@ page import="com.liferay.commerce.product.data.source.CPDataSourceResult" %>
<%
CPContentHelper cpContentHelper = (CPContentHelper)request.getAttribute(
CPContentWebKeys.CP_CONTENT_HELPER);
CPDataSourceResult cpDataSourceResult =
(CPDataSourceResult)request.getAttribute(
CPContentWebKeys.CP_DATA_SOURCE_RESULT);
%>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Product</th>
<th>SKU</th>
<th>Price</th>
<th>Availability</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="<%= cpDataSourceResult.getCPCatalogEntries() %>" var="cpCatalogEntry">
<%
CPCatalogEntry entry = (CPCatalogEntry)pageContext.getAttribute("cpCatalogEntry");
CPSku defaultSku = cpContentHelper.getDefaultCPSku(entry);
%>
<tr>
<td><%= entry.getName() %></td>
<td><%= (defaultSku != null) ? defaultSku.getSku() : "N/A" %></td>
<td><%= (defaultSku != null) ? defaultSku.getPrice() : "" %></td>
<td><%= cpContentHelper.getAvailabilityLabel(request) %></td>
<td>
<liferay-util:dynamic-include key="com.liferay.commerce.product.content.web#/add_to_cart#" />
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div> Notice how the table reuses <liferay-util:dynamic-include key="com.liferay.commerce.product.content.web#/add_to_cart#" /> instead of building custom cart JavaScript. That keeps your Custom Product List Renderer in Liferay Commerce aligned with Liferay's native React-based Add to Cart and quantity selector components.
Step 4: Add the Label to Language.properties
Create src/main/resources/content/Language.properties and define the translation key referenced by getLabel(Locale):
custom-b2b-table-list-renderer=Custom B2B Table List Renderer
Step 5: Deploy and Activate in the Widget UI
Once you build and deploy the module with ./gradlew deploy, open any page containing the Search Results or Product Publisher widget:
- Click the widget options menu and select Configuration.
- Under the Custom Renderer section, choose Custom B2B Table List Renderer from the dropdown.
- Save the configuration and refresh the page to see your table layout live.
Building production-ready OSGi renderers often involves custom CPContentHelper extensions, permission checks, and multi-channel styling. Teams that prefer to avoid common OSGi classloading or upgrade pitfalls often rely on Liferay Development Services to structure and maintain these modules cleanly.
Looking to speed up your storefront customization?
Hire Liferay developers to build custom product list renderers, OSGi modules, and B2B catalog layouts that stay clean across upgrades.
Once your Custom Product List Renderer in Liferay Commerce is deployed and working, a few technical habits will keep it fast, maintainable, and upgrade-safe in production.
1. Avoid Heavy Service Calls Inside the JSP Loop
In view.jsp, the <c:forEach> loop runs once for every product on the page. Calling Liferay local services (such as CPDefinitionLocalService or custom database queries) directly inside that loop creates an N+1 query bottleneck that slows down category and search pages.
Instead, rely on CPDataSourceResult and CPContentHelper, which read from Liferay's indexed search results and request-scoped helpers. Always guard against missing default SKUs when a product has multiple variants or an incomplete catalog.
<%
CPSku defaultSku = cpContentHelper.getDefaultCPSku(entry);
String skuCode = (defaultSku != null) ? defaultSku.getSku() : "Unavailable";
%>
If you need extra attributes (such as custom fields or ERP data) across the entire list, pre-fetch them in a single batch inside your Java render(...) method and pass a Map<Long, YourDto> to the JSP via httpServletRequest.setAttribute(...).
2. Protect Your OSGi Registry Keys
- Use unique keys for new layouts: Never reuse an out-of-the-box key (such as list-entry-default or Minimum renderer keys) unless your explicit goal is to replace Liferay's default renderer globally.
- Verify Bundle-SymbolicName alignment: Any mismatch between Bundle-SymbolicName in bnd.bnd and the osgi.web.symbolicname target on your ServletContext reference will prevent the module from resolving /view.jsp at runtime.
- Reuse native Commerce taglibs: Keep <liferay-util:dynamic-include> for interactive controls like Add to Cart and Compare instead of writing custom AJAX endpoints. This ensures your custom list works with Liferay's React frontend and headless cart APIs.
3. Keep Presentation Styles Out of Java
Store layout classes (such as Clay or Bootstrap grid and table classes) inside your JSP and theme CSS rather than building HTML strings inside your Java class. Separating markup from OSGi registration makes frontend updates much faster when your design system evolves.
Conclusion
Building a Custom Product List Renderer in Liferay Commerce gives engineering teams full control over how product collections are structured across Product Publisher, Search Results, and Compare widgets. By combining an OSGi CPContentListRenderer component with a clean view.jsp template and Liferay's native CPContentHelper utilities, you can deliver specialized B2B tables and custom catalog layouts without modifying core platform code.
At Surekha Technologies, our Liferay engineers help B2B and enterprise brands design and build custom product renderers, OSGi modules, and tailored storefront experiences that scale cleanly with every Liferay DXP upgrade. Whether you are launching a new commerce portal or refactoring an existing catalog layout, our team ensures your storefront stays fast, maintainable, and aligned with your buyers' workflows.
Frequently Asked Questions (FAQs)
What is the difference between CPContentListRenderer and CPContentRenderer in Liferay Commerce?
CPContentListRenderer controls the outer layout of multiple products inside widgets like Search Results and Product Publisher. In contrast, CPContentRenderer controls how a single product appears on its Product Details page based on its specific product type, such as Simple or Grouped.
Which Liferay Commerce widgets support a Custom Product List Renderer?
Out-of-the-box storefront widgets including Product Publisher, Search Results, and Compare support custom product list renderers. Once your OSGi module is deployed, site administrators can select your custom layout directly from each widget's Configuration menu under Custom Renderer.
Should I use a Custom Product List Renderer or a FreeMarker Widget Template?
Use a FreeMarker Widget Template for quick visual tweaks like adding a badge or adjusting HTML classes. Choose a Custom Product List Renderer when you need Java business logic, custom data pre-fetching, or reusable OSGi layouts across multiple storefront pages.
Why does my custom renderer fail to load its view.jsp file?
This usually happens when Bundle-SymbolicName in your bnd.bnd file does not match the osgi.web.symbolicname target on your ServletContext reference. Also verify that Web-ContextPath is defined in bnd.bnd so Liferay generates the module's web context at runtime.
Will creating a Custom Product List Renderer override Liferay's default layouts?
No, if you assign a unique key in both the @Component properties and the getKey() method. Your custom renderer will appear alongside Liferay's built-in options. Reusing an existing Liferay key is what overrides the default renderer.
How can Surekha Technologies help with Liferay Commerce renderer customization?
Surekha Technologies provides dedicated Liferay developers who build upgrade-safe OSGi renderers, B2B quick-order tables, and custom storefront layouts. We handle everything from module architecture and ERP data pre-fetching to testing across Search Results and Product Publisher widgets.