0

How can i use resource models for delete record instead of use delete method ?

Currently i used below code for delete item:

$post = $this->customCollection->load($itemId);
$post->delete();

but i need to use resource models for deleting data.

any idea please share.

7
  • check my answer: magento.stackexchange.com/questions/228593/… You want like this? Jun 5, 2018 at 11:45
  • No Nikunj, We need to use Resource model for delete data. Jun 5, 2018 at 12:26
  • At the end the function is in resource model, please provide more details about it.
    – kunj
    Jun 5, 2018 at 12:47
  • @kunj, in ResourceModel , there is one method _construct with code of $this->_init('modulename', 'id'); Jun 5, 2018 at 12:51
  • but you extended \Magento\Framework\Model\ResourceModel\Db\AbstractDb file in your custom resource. You will see public function delete(\Magento\Framework\Model\AbstractModel $object) method in that \Magento\Framework\Model\ResourceModel\Db\AbstractDb file.
    – kunj
    Jun 5, 2018 at 12:55

0

Your Answer

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

Browse other questions tagged or ask your own question.