use of org.broadleafcommerce.core.catalog.domain.ProductAttribute in project BroadleafCommerce by BroadleafCommerce.
the class I18nSolrIndexServiceExtensionHandler method startBatchEvent.
@Override
public ExtensionResultStatusType startBatchEvent(List<? extends Indexable> indexables) {
List<String> skuIds = new ArrayList<String>(indexables.size());
List<String> productIds = new ArrayList<String>();
List<String> skuAttributeIds = new ArrayList<String>();
List<String> productAttributeIds = new ArrayList<String>();
for (Indexable indexable : indexables) {
Sku sku = null;
if (Product.class.isAssignableFrom(indexable.getClass())) {
Product product = (Product) indexable;
productIds.add(product.getId().toString());
for (Map.Entry<String, ProductAttribute> attributeEntry : product.getProductAttributes().entrySet()) {
ProductAttribute attribute = attributeEntry.getValue();
productAttributeIds.add(attribute.getId().toString());
}
sku = product.getDefaultSku();
}
if (sku != null) {
skuIds.add(sku.getId().toString());
for (Map.Entry<String, SkuAttribute> attributeEntry : sku.getSkuAttributes().entrySet()) {
SkuAttribute attribute = attributeEntry.getValue();
skuAttributeIds.add(attribute.getId().toString());
}
}
}
addEntitiesToTranslationCache(skuIds, TranslatedEntity.SKU);
addEntitiesToTranslationCache(productIds, TranslatedEntity.PRODUCT);
addEntitiesToTranslationCache(skuAttributeIds, TranslatedEntity.SKU_ATTRIBUTE);
addEntitiesToTranslationCache(productAttributeIds, TranslatedEntity.PRODUCT_ATTRIBUTE);
return ExtensionResultStatusType.HANDLED_CONTINUE;
}
Aggregations