コード例 #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);
     }
 }
コード例 #2
0
 /**
  * Analyze referral code and get parent for the customer.
  *
  * @param int $customerId
  * @param int $parentId
  * @return int
  */
 public function getReferredParentId($customerId, $parentId)
 {
     /* use customer ID as parent ID if parent ID is missed */
     $result = $parentId ? $parentId : $customerId;
     $code = $this->_toolReferral->getReferralCode();
     if ($code) {
         $parentDo = $this->_repoCustomer->getByReferralCode($code);
         if ($parentDo) {
             $result = $parentDo->getCustomerId();
         }
     }
     return $result;
 }
コード例 #3
0
 /**
  * Extract referral code from GET-variable or cookie and save it into registry.
  *
  * @param \Magento\Framework\App\FrontControllerInterface $subject
  * @param \Magento\Framework\App\RequestInterface $request
  */
 public function beforeDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Magento\Framework\App\RequestInterface $request)
 {
     $reqCode = $request->getParam(static::REQ_REFERRAL);
     $this->_toolReferralCode->processHttpRequest($reqCode);
 }