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
file with the following content:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/ etc/routes.xsd"> <router id="standard"> <route id...