Create a repository in Magento
Learn how to create a Magento 2 PostRepository implement PostRepositoryInterface and configure di xml preferences.
Lesson Content
Now that you have a data interface and a repository interface defined, you can finally create a repository for the blog post entity.
The idea of a repository is that other code, like another module using your entities, shouldn’t care how the entity is stored or retrieved. The repository exposes public methods that others can call, while still letting you write the actual logic and database calls behind the scenes.
Create a file under the Model directory named PostRepository.php. This will be a standard PHP file where you declare strict types and set the namespace to `Macademy\Blog\Mo...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.