Set the last name for migrated customers to LEGACY. #487
This commit is contained in:
parent
51cdc6ff15
commit
77bc17d41e
2 changed files with 58 additions and 1 deletions
|
|
@ -55,6 +55,9 @@ class MigrateCMBLegacyJobOrderCommand extends Command
|
|||
remarks = 'remark'
|
||||
satisfaction => 'satisfaction'
|
||||
*/
|
||||
|
||||
const STR_LAST_NAME = 'LEGACY';
|
||||
|
||||
protected $em;
|
||||
|
||||
protected $bmanu_hash;
|
||||
|
|
@ -405,7 +408,7 @@ class MigrateCMBLegacyJobOrderCommand extends Command
|
|||
$new_cust = new Customer();
|
||||
|
||||
$new_cust->setFirstName($name)
|
||||
->setLastName('')
|
||||
->setLastName(self::STR_LAST_NAME)
|
||||
->setPhoneMobile($mobile);
|
||||
|
||||
$this->em->persist($new_cust);
|
||||
|
|
|
|||
54
src/Command/UpdateCMBMigratedCustomerCommand.php
Normal file
54
src/Command/UpdateCMBMigratedCustomerCommand.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\Customer;
|
||||
|
||||
class UpdateCMBMigratedCustomerCommand extends Command
|
||||
{
|
||||
// last name to set
|
||||
const STR_LAST_NAME = 'LEGACY';
|
||||
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cmbcustomer:updatecustomer')
|
||||
->setDescription('Set customer last name.')
|
||||
->setHelp('Set the customer last name. ');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
error_log('Updating customer last name...');
|
||||
|
||||
// get all customers
|
||||
$cust_results = $this->em->getRepository(Customer::class)->findBy(['last_name' => '']);
|
||||
|
||||
foreach ($cust_results as $cust)
|
||||
{
|
||||
$cust->setLastName(self::STR_LAST_NAME);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
$this->em->clear();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue