Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The variations just unset from the $product->variations and still exist in a DB.
Comments
Comment #3
drugan CreditAttribution: drugan as a volunteer commentedFor some reasons the $variation->delete(); statement has disappeared :).
So, to delete orphaned variations on an existing product just check in any variation on the product/N/variations page and apply Delete variations actions action. If there were some orphaned variations then the warning will appear. Just press the CANCEL AND BACK button and you are done with the cleanup work.
The things a little more complicated if you've already deleted a product with orphaned variations. If you are totally sure that ALL (!sic) your variations must have a parent product then execute the code below:
Comment #4
drugan CreditAttribution: drugan as a volunteer commented