removeProductFromCategory - only 4 lines of code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

removeProductFromCategory - only 4 lines of code

Patrick-4
I want removeProductFromCategory to remove a product from 2
categories, the default, and another one with productCategoryId=10300.
Since it's only 4 lines of code it seems like it should be really
simple, but I am really stuck.

<!-- here is the original code which works fine -->
 <make-value value-field="lookupPKMap" entity-name="ProductCategoryMember"/>
<set-pk-fields map="parameters" value-field="lookupPKMap"/>
<find-by-primary-key entity-name="ProductCategoryMember"
map="lookupPKMap" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
<!-- end original code  -->

<!-- here is my addition -  I make a copy of the parameters map, I set
the copy's productCategoryId to 10300, then I do the next three
operations with the new value.
-->
<map-to-map map="parameters" to-map="parametersCopy"/>
<set field="parametersCopy.productCategoryId" value="10300"/>

<make-value value-field="lookupPKMapCopy" entity-name="ProductCategoryMember"/>
<set-pk-fields map="parametersCopy" value-field="lookupPKMapCopy"/>
<find-by-primary-key entity-name="ProductCategoryMember"
map="lookupPKMapCopy" value-field="lookedUpValueCopy"/>
<remove-value value-field="lookedUpValueCopy"/>

The error I get is
"In remove-value a value was not found with the specified valueAcsr:
lookedUpValueCopy, not removing"

Many thanks in advance,  Patrick