コード例 #1
0
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $def = $this->manTrans->begin();
     try {
         foreach ($this->DEFAULT_DWNL_TREE as $custId => $parentId) {
             $first = 'User' . $custId;
             $last = 'Last';
             $email = "customer_{$custId}@test.com";
             if ($custId != $parentId) {
                 /* save parent ID to registry */
                 $referralCode = $this->mapCustomerMageIdByIndex[$parentId];
                 $this->toolReferral->replaceCodeInRegistry($referralCode);
             }
             /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
             $customer = $this->_manObj->create(\Magento\Customer\Api\Data\CustomerInterface::class);
             $customer->setEmail($email);
             $customer->setFirstname($first);
             $customer->setLastname($last);
             /* MOBI-427: change group ID for retail customers */
             if (in_array($custId, $this->GROUP_RETAIL)) {
                 $customer->setGroupId(BusinessCodesManager::M_CUST_GROUP_RETAIL);
             }
             /** @var \Magento\Customer\Api\Data\CustomerInterface $saved */
             $saved = $this->repoCustomer->save($customer, $this->DEFAULT_PASSWORD_HASH);
             $this->mapCustomerMageIdByIndex[$custId] = $saved->getId();
             $this->mapCustomerIndexByMageId[$saved->getId()] = $custId;
         }
         /* MOBI-426 : rename customer groups according to Generic App scheme. */
         $this->subCustomerGroups->renameGroups();
         $this->manTrans->commit($def);
     } finally {
         // transaction will be rolled back if commit is not done (otherwise - do nothing)
         $this->manTrans->end($def);
     }
 }