From 77bc17d41ee5d722633fa4f3e3630408d7b1f613 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 11 Sep 2020 07:50:17 +0000 Subject: [PATCH] Set the last name for migrated customers to LEGACY. #487 --- .../MigrateCMBLegacyJobOrderCommand.php | 5 +- .../UpdateCMBMigratedCustomerCommand.php | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/Command/UpdateCMBMigratedCustomerCommand.php diff --git a/src/Command/MigrateCMBLegacyJobOrderCommand.php b/src/Command/MigrateCMBLegacyJobOrderCommand.php index 2b42ddd0..11da2652 100644 --- a/src/Command/MigrateCMBLegacyJobOrderCommand.php +++ b/src/Command/MigrateCMBLegacyJobOrderCommand.php @@ -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); diff --git a/src/Command/UpdateCMBMigratedCustomerCommand.php b/src/Command/UpdateCMBMigratedCustomerCommand.php new file mode 100644 index 00000000..6189962f --- /dev/null +++ b/src/Command/UpdateCMBMigratedCustomerCommand.php @@ -0,0 +1,54 @@ +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; + } + +}