Search in sources :

Example 1 with SkuAttribute

use of org.broadleafcommerce.core.catalog.domain.SkuAttribute 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;
}
Also used : SkuAttribute(org.broadleafcommerce.core.catalog.domain.SkuAttribute) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) Indexable(org.broadleafcommerce.core.catalog.domain.Indexable) ProductAttribute(org.broadleafcommerce.core.catalog.domain.ProductAttribute) Sku(org.broadleafcommerce.core.catalog.domain.Sku) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Indexable (org.broadleafcommerce.core.catalog.domain.Indexable)1 Product (org.broadleafcommerce.core.catalog.domain.Product)1 ProductAttribute (org.broadleafcommerce.core.catalog.domain.ProductAttribute)1 Sku (org.broadleafcommerce.core.catalog.domain.Sku)1 SkuAttribute (org.broadleafcommerce.core.catalog.domain.SkuAttribute)1