Author: jleroux
Date: Thu Nov 8 15:07:44 2018
New Revision: 1846158
URL:
http://svn.apache.org/viewvc?rev=1846158&view=revLog:
Fixed: CatalogServices #duplicateProductCategory doesn't check for
existing categories
(OFBIZ-10328)
This method just crashes, if there is a category which has the same name as
the one the user is trying to create.
There should be a check for existing attributes and a clean return,
no exception throwing.
Thanks: Benjamin Jugl
Modified:
ofbiz/ofbiz-framework/trunk/applications/product/config/ProductUiLabels.xml
ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy
Modified: ofbiz/ofbiz-framework/trunk/applications/product/config/ProductUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/config/ProductUiLabels.xml?rev=1846158&r1=1846157&r2=1846158&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/config/ProductUiLabels.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/config/ProductUiLabels.xml Thu Nov 8 15:07:44 2018
@@ -14695,6 +14695,10 @@
<value xml:lang="de">Eine Attribut mit diesem Namen existiert bereits für die Produktgruppe mit dieser ID.</value>
<value xml:lang="en">There already is an attribute with this name for a group with this ID.</value>
</property>
+ <property key="ProductCategoryAlreadyExists">
+ <value xml:lang="de">Eine Produktgruppe mit dieser ID existiert bereits.</value>
+ <value xml:lang="en">There already is a Category with this ID.</value>
+ </property>
<property key="ProductCategoryNoVariants">
<value xml:lang="de">Keine Produkte mit den gewünschten Eigenschaften gefunden.</value>
<value xml:lang="en">No products which fit your requirements were found.</value>
Modified: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy?rev=1846158&r1=1846157&r2=1846158&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy Thu Nov 8 15:07:44 2018
@@ -529,6 +529,11 @@ def duplicateProductCategory() {
return error(UtilProperties.getMessage("ProductUiLabels", "ProductCatalogCreatePermissionError",
[resourceDescription: resourceDescription], parameters.locale))
}
+
+ if (findOne("ProductCategory", [productCategoryId: parameters.productCategoryId], false)) {
+ return error(UtilProperties.getMessage("ProductUiLabels", "ProductCategoryAlreadyExists",
+ [resourceDescription: resourceDescription], parameters.locale))
+ }
// look up the old product category and clone it
GenericValue oldCategory = from('ProductCategory').where([productCategoryId: parameters.oldProductCategoryId]).queryOne()