Author: deepak Date: Sat Mar 21 06:20:21 2015 New Revision: 1668198 URL: http://svn.apache.org/r1668198 Log: Hand merge fix from trunk r#1652624. ========================================= Log: Applied patch from jira issue OFBIZ-3563 which also resolves OFBIZ-2361. Creating a category with an ID (manually or automatically) that matches an existing productID will show the unrelated product when enter into the category on the 'Browse category' of the Ecommerce application.
Thanks Jonatan Soto and Rohit Sureka for reporting the issue. Thanks Divesh Dutta for providing patch for the fix. Modified: ofbiz/branches/release13.07/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java Modified: ofbiz/branches/release13.07/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java?rev=1668198&r1=1668197&r2=1668198&view=diff ============================================================================== --- ofbiz/branches/release13.07/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java (original) +++ ofbiz/branches/release13.07/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java Sat Mar 21 06:20:21 2015 @@ -36,6 +36,7 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; /** * ControlServlet.java - Master servlet for the web application. @@ -80,24 +81,26 @@ public class CatalogUrlServlet extends H String pathInfo = request.getPathInfo(); List<String> pathElements = StringUtil.split(pathInfo, "/"); - // look for productId String productId = null; + String categoryId = null; try { String lastPathElement = pathElements.get(pathElements.size() - 1); - if (lastPathElement.startsWith("p_") || delegator.findOne("Product", UtilMisc.toMap("productId", lastPathElement), true) != null) { - if (lastPathElement.startsWith("p_")) { - productId = lastPathElement.substring(2); + if (lastPathElement.startsWith("p_")) { + productId = lastPathElement.substring(2); + } else { + GenericValue productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", lastPathElement), true); + if (UtilValidate.isNotEmpty(productCategory)) { + categoryId = lastPathElement; } else { productId = lastPathElement; } - pathElements.remove(pathElements.size() - 1); } + pathElements.remove(pathElements.size() - 1); } catch (GenericEntityException e) { - Debug.logError(e, "Error looking up product info for ProductUrl with path info [" + pathInfo + "]: " + e.toString(), module); + Debug.logError(e, "Error in looking up ProductUrl or CategoryUrl with path info [" + pathInfo + "]: " + e.toString(), module); } // get category info going with the IDs that remain - String categoryId = null; if (pathElements.size() == 1) { CategoryWorker.setTrail(request, pathElements.get(0), null); categoryId = pathElements.get(0);