O'Reilly logo

Magento 2 Developer's Guide by Branko Ajzele

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an upgrade data script (UpgradeData.php)

The upgrade data script is the last one to execute. We will use it to demonstrate the example of creating the sample entries for our Department and Employee entities.

We start by creating the app/code/Foggyline/Office/Setup/UpgradeData.php file with (partial) content as follows:

namespace Foggyline\Office\Setup; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class UpgradeData implements UpgradeDataInterface { protected $departmentFactory; protected $employeeFactory; public function __construct( \Foggyline\Office\Model\DepartmentFactory $departmentFactory, \Foggyline\Office\Model\EmployeeFactory ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required