I have created a module that adds a custom table.

I also created a Model, ResourceModel and Collection classes, and was able to use them to insert data into this new table by calling the ModelFactory class and saving (save()) the data.

But I am wondering if this is the best practice or if I should create Api interfaces for doing that, or/and using Service Contract even if I don't want this class in Magento API.


You need:

  1. Resource Model for CRUD operations
  2. Model/ModelInterface for Data Modeling
  3. Repository/RepositoryInterface as frontend for database operations
  4. Custom table

Technically, you don't need interfaces but it is best practice and there is a reason behind it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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