You are browsing the documentation for version 3.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Fixtures and Demo Data

Before your application contains an interface to create new tasks, you need to load them programmatically. In OroPlatform, this can be done by creating classes that are placed in the Migrations/Data/ORM subdirectory of your bundle and that implement the FixtureInterface:

 1// src/AppBundle/Migrations/Data/ORM/LoadTasks.php
 2namespace AppBundle\Migrations\Data\ORM;
 4use AppBundle\Entity\Priority;
 5use AppBundle\Entity\Task;
 6use Doctrine\Common\DataFixtures\FixtureInterface;
 7use Doctrine\Common\Persistence\ObjectManager;
 9class LoadTasks implements FixtureInterface
11    public function load(ObjectManager $manager)
12    {
13        $majorPriority = new Priority();
14        $majorPriority->setLabel('major');
15        $manager->persist($majorPriority);
17        $importantTask = new Task();
18        $importantTask->setSubject('Important task');
19        $importantTask->setDescription('This is an important task');
20        $importantTask->setDueDate(new \DateTime('+1 week'));
21        $importantTask->setPriority($majorPriority);
22        $manager->persist($importantTask);
24        $minorPriority = new Priority();
25        $minorPriority->setLabel('minor');
26        $manager->persist($minorPriority);
28        $unimportantTask = new Task();
29        $unimportantTask->setSubject('Unimportant task');
30        $unimportantTask->setDescription('This is a not so important task');
31        $unimportantTask->setDueDate(new \DateTime('+2 weeks'));
32        $unimportantTask->setPriority($minorPriority);
33        $manager->persist($unimportantTask);
35        $manager->flush();
36    }

Use the oro:migration:data:load command to load all fixtures that have not been loaded yet:

$ php bin/console oro:migration:data:load


You can use the --dry-run option to first check which fixtures will be loaded:

$ php bin/console oro:migration:data:load


You can create data fixtures that should only be loaded when you want to to present your application with some demo data. To do so place your data fixture classes in the Migrations/Data/Demo/ORM subdirectory of your bundle and use the --fixtures-type option of the oro:migration:data:load command to indicate that the demo data should be loaded:

$ php bin/console oro:migration:data:load --fixtures-type=demo