Hard deleting products only hard deletes the product itself and not the purchasable + variant.
This in turn leads to users not being able to use the same SKU after the product has been hard deleted.
The delete events should also transfer if an element is hard/soft-deleted.
A related issue is with Neo: see https://github.com/spicywebau/craft-neo/blob/master/src/Field.php#L678-L690
馃憖
To get around this i'm just additionally hard deleting variants before I delete their products.
For reference, purchasables seem to get deleted with products, just not variants.
Craft version: 3.4.9
Craft Commerce version: 3.0.11
Craft::$app->getElements()->deleteElement($variant, true)
Yes this is our current approach as well
cc @lukeholder
Thanks, will get this fixed.
This has been fixed for the next release.
Thank you for bringing this to our attention.
A fix has been pushed and will be included in the next release.
To get this early, change your craftcms/commerce requirement in composer.json to:
"require": {
"craftcms/commerce": "dev-develop#fb041defb32ca21265923483efb01114188cfe58 as 3.1.1",
"...": "..."
}
Then run composer update
Thanks.
Most helpful comment
This has been fixed for the next release.
Thank you for bringing this to our attention.
A fix has been pushed and will be included in the next release.
To get this early, change your craftcms/commerce requirement in composer.json to:
Then run
composer updateThanks.