Wanted to understand data/logic flow of product component of CIF
Hi Team,
Can someone please explain me the logic of the CIF component: /apps/core/cif/components/commerce/product/v3/product
Foe testing purpose, I have deleted all the content from /apps/core/cif/components/commerce/product/v3/product/productFullDetail.html
Stil, in the logs I can see:
com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Cache hit for query
'{products(filter:{url_key:{eq:"carina-cardigan"}}){items{__typename,sku,url_key,name,description{html},image{label,url},thumbnail{l ....
That means, even if we are not rendering anything from Sightly component, still backend logic calls the GraphQL query to get the data.
Ofcourse, Sling model is called from: /apps/core/cif/components/commerce/product/v3/product/product.html
Can someone tell where exactly the logic is written to the GraphQL response:
I can see com.adobe.cq.commerce.core.components.models.retriever.AbstractProductRetriever
Here, method:
@Override
protected void populate() {
// Get product list from response
GraphqlResponse<Query, Error> response = executeQuery();
errors = response.getErrors();
if (CollectionUtils.isEmpty(errors)) {
Query rootQuery = response.getData();
List<ProductInterface> products = rootQuery.getProducts().getItems();
// Return first product in list unless the identifier type is 'url_key',
// then return the product whose 'url_key' matches the identifier
if (products.size() > 0) {
product = Optional.of(products.get(0));
} else {
product = Optional.empty();
}
} else {
product = Optional.empty();
}
}
Is this, the logic to get the particular product details. If yes, which method calls this. I was traversing through : com.adobe.cq.commerce.core.components.internal.models.v3.product.ProductImpl and then its super classes to crack the logic. Still, I am bit confused here.
Can someone help to crack the logic of this component.
cc: @hemalatha @amanath_ullah @mukeshyadav_
Thanks in advance.