Magento 2 : Use aftersave and beforesave method
you can used _beforeSave
and _afterSave
in your ResourceModel
<?php
namespace Spacename\Modulename\Model\ResourceModel;
class Test extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb {
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
// do your logic here
}
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
{
//do your logic here
}
}