Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard deleting products doesn't hard delete it's variant and purchasable #1186

Closed
gijsstegehuis opened this issue Dec 18, 2019 · 7 comments
Closed
Assignees
Labels

Comments

@gijsstegehuis
Copy link
Contributor

Description

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.

Steps to reproduce

  1. Add a product with variant
  2. Hard delete the product
  3. Add a new product using the same variant SKU used in step 1

Additional info

  • Craft version: 3.3.18.2
  • PHP version: 7.3.12
  • Database driver & version: PostgreSQL 11.5
  • Plugins & versions: -
@boboldehampsink
Copy link
Contributor

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

@mediabeastnz
Copy link
Contributor

👀

@mediabeastnz
Copy link
Contributor

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)

@boboldehampsink
Copy link
Contributor

Yes this is our current approach as well

@boboldehampsink
Copy link
Contributor

cc @lukeholder

@lukeholder lukeholder added the bug label Mar 11, 2020
@lukeholder
Copy link
Member

Thanks, will get this fixed.

@lukeholder
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants