I somehow ended up with an entry in commerce_product__variations with a variations_target_id referencing a deleted variation.
Deleting said product programmatically then results in:
TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php on line 688 #0 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(688): get_clas
s(NULL)
#1 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(480): Drupal\Core\Entity\EntityStorageBase->getEntitiesByClass(Array)
#2 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(751): Drupal\Core\Entity\EntityStorageBase->delete(Array)
#3 /app/web/modules/contrib/commerce/modules/product/src/Entity/Product.php(312): Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete(Array)
#4 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(494): Drupal\commerce_product\Entity\Product::postDelete(Object(Drupal\commerce\CommerceContentEntityStorage), Array)
#5 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(751): Drupal\Core\Entity\EntityStorageBase->delete(Array)
#6 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(347): Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete(Array)
#7 /app/web/core/modules/migrate/src/Plugin/migrate/destination/Entity.php(217): Drupal\Core\Entity\EntityBase->delete()
#8 /app/web/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php(395): Drupal\migrate\Plugin\migrate\destination\Entity->rollback(Array)
I do not know how to reproduce this invalid state.
But I'd like to offer a patch to at least be able to delete it successfully.
Comments
Comment #2
abhishek_gupta1 commentedComment #4
abhishek_gupta1 commented@rszrama , I have verified above patch, its working for me , also I created MR.
Comment #7
jsacksick commentedMerged, thanks.
Comment #8
abhishek_gupta1 commented