Customizing the Installation Process
To customize the installation process and modify the database structure and/or data that are loaded in the OroCommerce after installation, you can:
Execute Custom Migrations
You can create your own migrations that can be executed during the installation.
A migration is a class which implements the Oro\Bundle\MigrationBundle\Migration\Migration
interface:
namespace Acme\Bundle\DemoBundle\Migrations\Schema\v1_0;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
class CustomMigration implements Migration
{
/**
* @inheritDoc
*/
public function up(Schema $schema, QueryBag $queries)
{
// ...
}
}
Note
Entity metadata in the PHP entity classes (attributes) should exactly match what the schema migration is doing. If you create a migration that modifies the type, length, or another property of an existing entity field, please remember to make the same change in the PHP entity class attributes.
In the Oro\Bundle\MigrationBundle\Migration\Migration::up
, you can modify the database schema and/or add additional SQL queries executed before and after the schema changes.
Load Custom Data Fixtures
To load your own data fixtures, you will need to implement Doctrine’s “FixtureInterface”:
namespace Acme\Bundle\DemoBundle\Migrations\Data\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Persistence\ObjectManager;
class CustomFixture implements FixtureInterface
{
/**
* @inheritDoc
*/
public function load(ObjectManager $manager)
{
// ...
}
}
Caution
Your data fixture classes must reside in the “Migrations/Data/ORM” sub-directory of your bundle to be loaded automatically during the installation.
Tip
Read the doctrine data fixtures documentation to learn more about the Doctrine Data Fixtures extension.