当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomerRepositoryInterface::delete方法代码示例

本文整理汇总了PHP中Magento\Customer\Api\CustomerRepositoryInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomerRepositoryInterface::delete方法的具体用法?PHP CustomerRepositoryInterface::delete怎么用?PHP CustomerRepositoryInterface::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Api\CustomerRepositoryInterface的用法示例。


在下文中一共展示了CustomerRepositoryInterface::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDelete

 /**
  * @magentoAppArea adminhtml
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoAppIsolation enabled
  */
 public function testDelete()
 {
     $fixtureCustomerEmail = 'customer@example.com';
     $customer = $this->customerRepository->get($fixtureCustomerEmail);
     $this->customerRepository->delete($customer);
     /** Ensure that customer was deleted */
     $this->setExpectedException('Magento\\Framework\\Exception\\NoSuchEntityException', 'No such entity with email = customer@example.com, websiteId = 1');
     $this->customerRepository->get($fixtureCustomerEmail);
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:14,代码来源:CustomerRepositoryTest.php

示例2: testCustomerDeletedAdminArea

 /**
  * @magentoAppArea adminhtml
  * @magentoDataFixture Magento/Newsletter/_files/subscribers.php
  */
 public function testCustomerDeletedAdminArea()
 {
     $customer = $this->customerRepository->getById(1);
     $objectManager = Bootstrap::getObjectManager();
     /** @var \Magento\Newsletter\Model\Subscriber $subscriber */
     $subscriber = $objectManager->create('Magento\\Newsletter\\Model\\Subscriber');
     $subscriber->loadByEmail('customer@example.com');
     $this->assertTrue($subscriber->isSubscribed());
     $this->customerRepository->delete($customer);
     $this->verifySubscriptionNotExist('customer@example.com');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:PluginTest.php

示例3: createAccountWithPasswordHash

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function createAccountWithPasswordHash(CustomerInterface $customer, $hash, $redirectUrl = '')
 {
     // This logic allows an existing customer to be added to a different store.  No new account is created.
     // The plan is to move this logic into a new method called something like 'registerAccountWithStore'
     if ($customer->getId()) {
         $customer = $this->customerRepository->get($customer->getEmail());
         $websiteId = $customer->getWebsiteId();
         if ($this->isCustomerInStore($websiteId, $customer->getStoreId())) {
             throw new InputException(__('This customer already exists in this store.'));
         }
         // Existing password hash will be used from secured customer data registry when saving customer
     }
     // Make sure we have a storeId to associate this customer with.
     if (!$customer->getStoreId()) {
         if ($customer->getWebsiteId()) {
             $storeId = $this->storeManager->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
         } else {
             $storeId = $this->storeManager->getStore()->getId();
         }
         $customer->setStoreId($storeId);
     }
     // Update 'created_in' value with actual store name
     if ($customer->getId() === null) {
         $storeName = $this->storeManager->getStore($customer->getStoreId())->getName();
         $customer->setCreatedIn($storeName);
     }
     $customerAddresses = $customer->getAddresses() ?: [];
     $customer->setAddresses(null);
     try {
         // If customer exists existing hash will be used by Repository
         $customer = $this->customerRepository->save($customer, $hash);
     } catch (AlreadyExistsException $e) {
         throw new InputMismatchException(__('A customer with the same email already exists in an associated website.'));
     } catch (LocalizedException $e) {
         throw $e;
     }
     try {
         foreach ($customerAddresses as $address) {
             $address->setCustomerId($customer->getId());
             $this->addressRepository->save($address);
         }
     } catch (InputException $e) {
         $this->customerRepository->delete($customer);
         throw $e;
     }
     $customer = $this->customerRepository->getById($customer->getId());
     $newLinkToken = $this->mathRandom->getUniqueHash();
     $this->changeResetPasswordLinkToken($customer, $newLinkToken);
     $this->sendEmailConfirmation($customer, $redirectUrl);
     return $customer;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:56,代码来源:AccountManagement.php


注:本文中的Magento\Customer\Api\CustomerRepositoryInterface::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。