In this blog, we will discuss how to regenerate an entity in akeneo6 using CLI. If you have already maked an entity and you want to add a new field and use the setter and the getter method, in this solution no need to write the setter and the getter method yourself, you can generate the setter and the getter method using CLI.
you need to follow below few steps-
Step -1: if you have not to install MakerBundle, you will need to install Symfony MakerBundle. use given below composer command and install.
composer require --dev symfony/maker-bundle
Step-2: go to PIM root directory “config/bundles.php” and register MakerBundle
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true, 'test' => true, 'prod' => true]
Step-3: Now open your existing entity class (e.g. Acme/Bundle/NotifyConnectorBundle/Entity/User.php).
<?php namespace Acme\Bundle\NotifyConnectorBundle\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\Orm\Mapping as ORM; class User{ /* * @var string */ protected $designation; /* * @var string */ protected $department; }
Step-4: Run the given below command
php bin/console make:entity --regenerate "Acme\Bundle\NotifyConnectorBundle\Entity\User"
After executing the command, now depending on what your defined variable will has been generated the setter and the getter method.
Thank you!