Skip to content

Commit f0e641b

Browse files
author
jefffischer
committed
Merge remote-tracking branch 'upstream/BroadleafCommerce-4.0.x' into BroadleafCommerce-4.0.x
2 parents a197e6b + 0e7850f commit f0e641b

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)
149149
Broadleaf Commerce core is released under the terms of the Apache Software License 2 (see license.txt). However, various commercial modules that are also available (for instance, price list management) are released under a different commercial license. These are not included with the core Broadleaf framework.
150150

151151
We also offer various levels of [enterprise support licenses](http://broadleafcommerce.com/support). Please [contact us](http://broadleafcommerce.com/contact) for information.
152+
153+
## New Version
154+
155+
Our latest version is 5.0 and is licensed under a new dual license format. It may be used under the terms of the Fair Use License 1.0 (http://license.broadleafcommerce.org/fair_use_license-1.0.txt) unless the restrictions on use therein are violated and require payment to Broadleaf, in which case the Broadleaf End User License Agreement (EULA), Version 1.1 (http://license.broadleafcommerce.org/commercial_license-1.1.txt) shall apply. Alternatively, the Commercial License may be replaced with a mutually agreed upon license between you and Broadleaf Commerce.
156+
157+
To get started with the latest version of Broadleaf Commerce, please visit our getting started page on the web: http://www.broadleafcommerce.com/docs/core/current/getting-started

common/src/main/java/org/broadleafcommerce/common/i18n/service/TranslationServiceImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,13 @@ public String getTranslatedValue(Object entity, String property, Locale locale)
175175
localeCountryCode += "_" + locale.getCountry();
176176
}
177177

178-
if (TranslationBatchReadCache.getCache() != null) {
178+
if (TranslationBatchReadCache.getCache() != null && TranslationBatchReadCache.getCache().getSize() != 0) {
179179
Translation translation = TranslationBatchReadCache.getFromCache(entityType, entityId, property, localeCountryCode);
180180
if (translation != null) {
181181
return translation.getTranslatedValue();
182+
} else {
183+
// There is no translation for this entity if it is not in the cache
184+
return null;
182185
}
183186
}
184187

core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/search/service/solr/I18nSolrSearchServiceExtensionHandler.java

+38-14
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import org.broadleafcommerce.common.util.BLCSystemProperty;
3333
import org.broadleafcommerce.common.web.BroadleafRequestContext;
3434
import org.broadleafcommerce.core.catalog.domain.Product;
35+
import org.broadleafcommerce.core.catalog.domain.ProductAttribute;
3536
import org.broadleafcommerce.core.catalog.domain.Sku;
37+
import org.broadleafcommerce.core.catalog.domain.SkuAttribute;
3638
import org.broadleafcommerce.core.search.domain.Field;
3739
import org.broadleafcommerce.core.search.domain.solr.FieldType;
3840
import org.springframework.stereotype.Service;
@@ -204,28 +206,50 @@ protected ExtensionResultStatusType getLocalePrefix(Field field, List<String> pr
204206
*/
205207
@Override
206208
public ExtensionResultStatusType startBatchEvent(List<Product> products) {
207-
List<String> defaultSkuIds = new ArrayList<String>(products.size());
208-
List<String> productIds = new ArrayList<String>(products.size());
209-
for (Product product : products) {
210-
productIds.add(product.getId().toString());
211-
defaultSkuIds.add(product.getDefaultSku().getId().toString());
209+
List<String> skuIds = new ArrayList<String>(products.size());
210+
List<String> productIds = new ArrayList<String>();
211+
List<String> skuAttributeIds = new ArrayList<String>();
212+
List<String> productAttributeIds = new ArrayList<String>();
213+
for (Product indexable : products) {
214+
Sku sku = null;
215+
if (Product.class.isAssignableFrom(indexable.getClass())) {
216+
Product product = indexable;
217+
productIds.add(product.getId().toString());
218+
for (Map.Entry<String, ProductAttribute> attributeEntry : product.getProductAttributes().entrySet()) {
219+
ProductAttribute attribute = attributeEntry.getValue();
220+
productAttributeIds.add(attribute.getId().toString());
221+
}
222+
sku = product.getDefaultSku();
223+
}
224+
225+
if (sku != null) {
226+
skuIds.add(sku.getId().toString());
227+
for (Map.Entry<String, SkuAttribute> attributeEntry : sku.getSkuAttributes().entrySet()) {
228+
SkuAttribute attribute = attributeEntry.getValue();
229+
skuAttributeIds.add(attribute.getId().toString());
230+
}
231+
}
212232
}
213-
214-
List<Translation> defaultSkuTranslations = translationDao.readAllTranslationEntries(TranslatedEntity.SKU, ResultType.STANDARD, defaultSkuIds);
215-
TranslationBatchReadCache.addToCache(defaultSkuTranslations);
216-
217-
List<Translation> productTranslations = translationDao.readAllTranslationEntries(TranslatedEntity.PRODUCT, ResultType.STANDARD, productIds);
218-
TranslationBatchReadCache.addToCache(productTranslations);
219-
233+
234+
addEntitiesToTranslationCache(skuIds, TranslatedEntity.SKU);
235+
addEntitiesToTranslationCache(productIds, TranslatedEntity.PRODUCT);
236+
addEntitiesToTranslationCache(skuAttributeIds, TranslatedEntity.SKU_ATTRIBUTE);
237+
addEntitiesToTranslationCache(productAttributeIds, TranslatedEntity.PRODUCT_ATTRIBUTE);
238+
220239
return ExtensionResultStatusType.HANDLED_CONTINUE;
221240
}
222-
241+
242+
private void addEntitiesToTranslationCache(List<String> entityIds, TranslatedEntity translatedEntity) {
243+
List<Translation> translations = translationDao.readAllTranslationEntries(translatedEntity, ResultType.STANDARD, entityIds);
244+
TranslationBatchReadCache.addToCache(translations);
245+
}
246+
223247
@Override
224248
public ExtensionResultStatusType endBatchEvent() {
225249
TranslationBatchReadCache.clearCache();
226250
return ExtensionResultStatusType.HANDLED_CONTINUE;
227251
}
228-
252+
229253
@Override
230254
public int getPriority() {
231255
return 1000;

0 commit comments

Comments
 (0)