Author: jleroux
Date: Fri Jun 4 11:43:41 2010 New Revision: 951381 URL: http://svn.apache.org/viewvc?rev=951381&view=rev Log: A patch from Sascha Rodekamp "Duplicate Product, didn't duplicate the content" (https://issues.apache.org/jira/browse/OFBIZ-3804) - OFBIZ-3804 The Product duplicate function didn't really duplicate the product content, just set a reference to the original content. When I now change the content from the duplicated product, the content of the original product is changed to. So here is a patch that dublicate the content, dataresource and electronic text (if exists), too. The result is a true copy of the original product that can be edit without side effects to the original product. Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml?rev=951381&r1=951380&r2=951381&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml Fri Jun 4 11:43:41 2010 @@ -229,6 +229,37 @@ under the License. <iterate entry="foundValue" list="foundValues"> <clone-value value-field="foundValue" new-value-field="newTempValue"/> <set from-field="parameters.productId" field="newTempValue.productId"/> + <!-- Clone Content --> + <sequenced-id sequence-name="Content" field="newContentId"/> + <entity-one entity-name="Content" value-field="oldContent" use-cache="false"> + <field-map field-name="contentId" value="${newTempValue.contentId}"/> + </entity-one> + <if-not-empty field="oldContent"> + <clone-value value-field="oldContent" new-value-field="clonedContent"/> + <set from-field="newContentId" field="clonedContent.contentId"/> + <set from-field="newContentId" field="newTempValue.contentId"/> + <!-- Clone DataResource --> + <entity-one entity-name="DataResource" value-field="oldDataResource" use-cache="false"> + <field-map field-name="dataResourceId" value="${clonedContent.dataResourceId}"/> + </entity-one> + <if-not-empty field="oldDataResource"> + <sequenced-id sequence-name="DataResource" field="newDataResourceId"/> + <clone-value new-value-field="clonedDataresource" value-field="oldDataResource"/> + <set from-field="newDataResourceId" field="clonedDataresource.dataResourceId"/> + <!-- set new data resource id in cloned content --> + <set from-field="newDataResourceId" field="clonedContent.dataResourceId"/> + <create-value value-field="clonedDataresource"/> + <!-- Clone Electronic Text if exists --> + <get-related-one value-field="oldDataResource" relation-name="ElectronicText" to-value-field="oldElectronicText"/> + <if-not-empty field="oldElectronicText"> + <clone-value value-field="oldElectronicText" new-value-field="clonedElectronicText"/> + <set from-field="newDataResourceId" field="clonedElectronicText.dataResourceId"/> + <create-value value-field="clonedElectronicText"/> + </if-not-empty> + </if-not-empty> + <create-value value-field="clonedContent"/> + </if-not-empty> + <!-- End Clone Contet --> <create-value value-field="newTempValue"/> </iterate> </if-not-empty> |
Free forum by Nabble | Edit this page |