This is caused when the product is loaded into memory and associated with a child collection of another object. For products this is typically caused by category or product relationships such a related products or variants.
I need to know more about the code to be more specific.
Basically, I'm trying to override the delete variant button on the EditProductVariants page so that i can check if the variant has been purchased and only allow it to be deleted if it hasn't.
I've gotten passed the error above but i still can't actually delete the variants. Below is the code i'm using, the product appears to be deleted but is still in the db and returns when i refresh the product
Delete products from code
Hi,
How can I delete a product from code?
When I call .Delete() on the product i get the following error
deleted object would be re-saved by cascade (remove deleted object from associations)[UCommerce.EntitiesV2.Product#4466]
Thanks,
Matt
Hi Matt,
This is caused when the product is loaded into memory and associated with a child collection of another object. For products this is typically caused by category or product relationships such a related products or variants.
I need to know more about the code to be more specific.
Hi Soren,
Basically, I'm trying to override the delete variant button on the EditProductVariants page so that i can check if the variant has been purchased and only allow it to be deleted if it hasn't.
I've gotten passed the error above but i still can't actually delete the variants. Below is the code i'm using, the product appears to be deleted but is still in the db and returns when i refresh the product
Thanks,
Matt
Try this instead:
The save method will cascade deletes for you.
Thanks
is working on a reply...