In broadleaf, I can see that the sku contains the skuAttributes
. But when I try to invoke the product info using the endpoint /catalog/product/{id}..
am do not see the skuAttributes
coming in the api response. How can I get those sku attributes values as part of the response?
You will need to override the SkuWrapper
bean in an @Configuration
class. Example:
@Configuration
public class ApiWrapperOverrides {
@Bean
@Scope("prototype")
public MySkuWrapper blSkuWrapper() {
return new MySkuWrapper();
}
}
public class MySkuWrapper extends SkuWrapper {
@XmlElement(name = "skuAttribute")
@XmlElementWrapper(name = "skuAttributes")
protected List<SkuAttributeWrapper> skuAttributes = new ArrayList<>();
@Override
public void wrapDetails(Sku model, HttpServletRequest request) {
super.wrapDetails(sku, request);
if (model.getSkuAttributes() != null && !model.getSkuAttributes().isEmpty()) {
for (Map.Entry<String, SkuAttribute> entry : model.getSkuAttributes().entrySet()) {
wrapper.wrapSummary(entry.getValue(), request);
skuAttributes.add(wrapper);
}
}
}
}