ashsmith / magento2-blog-module-tutorial

A tutorial on how create a magento 2 module from scratch, with tests.
https://www.ashsmith.io/magento2/module-from-scratch-introduction/
111 stars 59 forks source link

Follow best practises around data models #21

Open ashsmith opened 7 years ago

ashsmith commented 7 years ago

We should follow best practises set out by Magento by using data models to access our blog posts.

I'm going to implement the following

Then modify Ashsmith\Blog\Model\Post so that it no longer uses the interface, and has the method getDataModel.

PostRepositoryInterface should define the following methods:

Any reference to loading the collections, or the original Post model directly will be switched out for the PostRepository.