Entity CRUD actions

Up to this point, we have learned how to create a simple model, an EAV model, and install and upgrade types of schema and data script. Now, let us see how we can create, read, update and delete our entities, operations that are commonly referred to as CRUD.

Though this chapter is about models, collections, and related things, for the purpose of demonstration, let's make a tiny detour into routes and controllers. The idea is to create a simple Test controller with the Crud action we can trigger in the browser via a URL. Within this Crud action, we will then dump our CRUD-related code.

To make Magento respond to the URL we punch into the browser, we need to define the route. We do so by creating the app/code/Foggyline/Office/etc/frontend/routes.xml ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.