0

I have a two table one is "tbl_subscription('entity_id', subscription_id, title)" another is "tbl_subs_pro('entity id''subscription_id' 'sku')" when i click on delete option from admin grid . the records will deleted from both table. subscription id is a Foreign key.

2 Answers 2

0

You seem to want to set ON DELETE CASCADE for the subscription_id foreign key, which will trigger that deleting a row in the parent table will delete all rows referencing the deleted record in the foreign keys table.

If you use XML declarative schema, you can use set onDelete="CASCADE" on your foreign key constraint in the db_schema.xml.

If you used InstallSchema.php, you can also specifiy ON DELETE CASCADE, by setting the onDelete parameter to \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE in your addForeignKey call.

0

You can simply delete it from delete controller file. Based on entity_id, load the model of tbl_subscription and delete then load model of tbl_subs_pro and delete it.

Let me know if you need more help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.