Magento2: Magento\Framework\Model\AbstractModel->save() is deprecated. What i should use instead of that?

Created on 12 Apr 2016  路  8Comments  路  Source: magento/magento2

Hi guys. Since that https://github.com/magento/magento2/commit/02b9213e4468bfa765ecc38ee55657662554fd72 commit AbstractModel->save() method is deprecated. Please someone tell me, what i should use for save it ?

Format is not valid

All 8 comments

For now, you should use ResourceModel->save(). Entity should not have persistence operations, so this method was deprecated.

Big thanks.

Entity should not have persistence operations, so this method was deprecated.

I agree but this could have been realized before...

Is there an example anywhere of how to actually use ResourceModel?

@jreinke, the approach with persistence on models was implemented 10 years ago.

Thanks for the example! I was looking at the (hopefully simpler) newsletter and review module cases, but they used the deprecated approach.

Still, your example uses "load" which also is deprecated: https://github.com/magento/magento2/blob/2.2.0/app/code/Magento/Catalog/Model/ProductRepository.php#L271

Was this page helpful?
0 / 5 - 0 ratings