Fixed: CatalogServices #duplicateProductCategory doesn't check for
existing categories
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
@@ -530,6 +530,11 @@ def duplicateProductCategory() {
[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()
GenericValue newCategory = oldCategory.clone()
