The grid widget

Instead of having to write our own grid blocks from scratch, we can reuse the ones that are already provided by the Magento Adminhtml module.

The block that we will be extending is called the grid widget. The grid widget is a special type of block designed to render a collection of Magento objects in a particular table grid.

A grid widget is normally rendered inside a grid container. The combination of both elements not only allows us to display our data in grid form, but also adds search, filtering, sorting, and mass action capabilities. Perform the following steps:

  1. Navigate to the block's Adminhtml/ folder and create a folder named Giftregistry/.
  2. Create a class called List.php inside that folder.
  3. Copy the following code inside List.php ...

Get Magento PHP Developer's Guide - Second Edition 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.