Hello Community,
We are in the process of migrating from a traditional AEM storefront implementation with CIF components to Catalog Service, and we are facing challenges with Product Listing Pages (PLP).
Currently, our PLPs use queries like:
query {
products(filter: { sku: { in: ["8429420181151", "8718117612253", "8470001995292", ...] }}) {
items {
__typename
sku
price_range {
minimum_price {
regular_price { value currency }
final_price { value currency }
}
}
...
}
}
}
But we need to switch to Catalog Service with productSearch, for example:
query ProductSearchPLP_WithPrices(
$phrase: String!,
$current_page: Int = 1,
$page_size: Int = 1,
$filter: [SearchClauseInput!],
$sort: [ProductSearchSortInput!],
$context: QueryContextInput
) {
productSearch(
phrase: $phrase,
current_page: $current_page,
page_size: $page_size,
filter: $filter,
sort: $sort,
context: $context
) {
total_count
items {
product {
sku
name
price_range {
minimum_price { final_price { value currency } regular_price { value currency } }
maximum_price { final_price { value currency } regular_price { value currency } }
}
}
productView {
id sku name url description
images { url label roles }
attributes { name value }
}
}
}
}
The issue is that our catalog is very large, so performance and scalability are critical.
When reviewing the archetype of the current implementation for ProductList, we see something like this:
@Override
public Collection<ProductListItem> getProducts() {
List<ProductListItem> products = new ArrayList<>(productList.getProducts());
products.sort((a, b) -> {
String aStock = getStockStatusFromProduct(a);
String bStock = getStockStatusFromProduct(b);
boolean aAvailable = "IN_STOCK".equalsIgnoreCase(aStock);
boolean bAvailable = "IN_STOCK".equalsIgnoreCase(bStock);
if (aAvailable == bAvailable) return 0;
return aAvailable ? -1 : 1; // In-stock products first
});
return products;
}
My questions are:
What is the recommended way to intercept or replace the query executed by CIF components (e.g., ProductListImpl) so that we can move from products(filter: { sku: { in: [...] }}) to productSearch in Catalog Service?
Is creating a custom ProductCollection implementation the right approach, or are there best practices/extensions already defined for this migration?
Any guidance, examples, or pointers to documentation on how/where to customize the query in the CIF component flow would be greatly appreciated.
Thanks in advance!