Author: mbrohl
Date: Tue Mar 13 19:37:57 2018
New Revision: 1826671
URL: http://svn.apache.org/viewvc?rev=1826671&view=rev
Log:
Fixed: Wrong locale/fallbackLocale logic in CategoryContentWrapper leads
to unavailable alternate locale content.
(OFBIZ-10274)
Thanks Martin Becker for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java?rev=1826671&r1=1826670&r2=1826671&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
Tue Mar 13 19:37:57 2018
@@ -34,7 +34,6 @@ import org.apache.ofbiz.base.util.Genera
import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilCodec;
import org.apache.ofbiz.base.util.UtilHttp;
-import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.base.util.cache.UtilCache;
import org.apache.ofbiz.content.content.ContentWorker;
@@ -143,25 +142,8 @@ public class CategoryContentWrapper impl
throw new GeneralRuntimeException("Unable to find a delegator to
use!");
}
- List<GenericValue> categoryContentList =
EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId",
productCategoryId, "prodCatContentTypeId",
prodCatContentTypeId).orderBy("-fromDate").cache(cache).queryList();
- categoryContentList = EntityUtil.filterByDate(categoryContentList);
-
- GenericValue categoryContent = null;
- String sessionLocale = (locale != null ? locale.toString() : null);
- String fallbackLocale = UtilProperties.getFallbackLocale().toString();
- if ( sessionLocale == null ) sessionLocale = fallbackLocale;
- // look up all content found for locale
- for( GenericValue currentContent: categoryContentList ) {
- GenericValue content =
EntityQuery.use(delegator).from("Content").where("contentId",
currentContent.getString("contentId")).cache(cache).queryOne();
- if ( sessionLocale.equals(content.getString("localeString")) ) {
- // valid locale found
- categoryContent = currentContent;
- break;
- } else if (
fallbackLocale.equals(content.getString("localeString")) ) {
- // fall back to default locale
- categoryContent = currentContent;
- }
- }
+ List<GenericValue> categoryContentList =
EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId",
productCategoryId, "prodCatContentTypeId",
prodCatContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
+ GenericValue categoryContent =
EntityUtil.getFirst(categoryContentList);
if (categoryContent != null) {
// when rendering the category content, always include the Product
Category and ProductCategoryContent records that this comes from
Map<String, Object> inContext = new HashMap<String, Object>();