• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Model\CustomerFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Customer\Model\CustomerFactory的典型用法代码示例。如果您正苦于以下问题:PHP CustomerFactory类的具体用法?PHP CustomerFactory怎么用?PHP CustomerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * @param \Magento\Framework\Session\SessionManagerInterface $session
  * @param \Magento\Customer\Model\Session $customerSession
  * @param \Magento\Customer\Model\CustomerFactory $customerFactory
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\Module\Manager $moduleManager
  * @param \Magento\Log\Model\Visitor $visitor
  * @param \Magento\PageCache\Model\Config $cacheConfig
  */
 public function __construct(\Magento\Framework\Session\SessionManagerInterface $session, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Module\Manager $moduleManager, \Magento\Log\Model\Visitor $visitor, \Magento\PageCache\Model\Config $cacheConfig)
 {
     $this->session = $session;
     $this->customerSession = $customerSession;
     $this->customer = $customerFactory->create();
     $this->request = $request;
     $this->moduleManager = $moduleManager;
     $this->visitor = $visitor;
     $this->cacheConfig = $cacheConfig;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:DepersonalizePlugin.php


示例2: setUp

 /**
  * SetUp
  */
 protected function setUp()
 {
     $this->layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $this->sessionMock = $this->getMock('Magento\\Framework\\Session\\Generic', ['clearStorage', 'setData', 'getData'], [], '', false);
     $this->customerSessionMock = $this->getMock('Magento\\Customer\\Model\\Session', ['getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer'], [], '', false);
     $this->customerFactoryMock = $this->getMock('Magento\\Customer\\Model\\CustomerFactory', ['create'], [], '', false);
     $this->customerMock = $this->getMock('Magento\\Customer\\Model\\Customer', ['setGroupId', '__wakeup'], [], '', false);
     $this->visitorMock = $this->getMock('Magento\\Customer\\Model\\Visitor', [], [], '', false);
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->customerMock));
     $this->depersonalizeCheckerMock = $this->getMock('Magento\\PageCache\\Model\\DepersonalizeChecker', [], [], '', false);
     $this->plugin = new \Magento\Customer\Model\Layout\DepersonalizePlugin($this->depersonalizeCheckerMock, $this->sessionMock, $this->customerSessionMock, $this->customerFactoryMock, $this->visitorMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:DepersonalizePluginTest.php


示例3: indexAction

 public function indexAction()
 {
     if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
         /** define operator name */
         /** @var $session Mage_Admin_Model_Session */
         $session = $this->backendAuthSession;
         if ($session->isLoggedIn()) {
             /** @var $user Mage_Admin_Model_User */
             $user = $session->getUser();
             $operator = $user->getName() . ' (' . $user->getEmail() . ')';
             /** if there is customer data in request */
             if (!is_null($this->getRequest()->getParams())) {
                 $params = $this->getRequest()->getParams();
                 if (!is_null($params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID])) {
                     /** extract customer ID from request and load customer data */
                     $customerId = $params[Praxigento_LoginAs_Config::REQ_PARAM_LAS_ID];
                     /** @var $customer Mage_Customer_Model_Customer */
                     $customer = $this->customerCustomerFactory->create()->load($customerId);
                     if ($customer->getId() == $customerId) {
                         $customerName = $customer->getName();
                         /** define URL to login to customer's website */
                         $wsId = $customer->getData('website_id');
                         if (is_null($wsId)) {
                             $wsId = $this->storeManager->getStore()->getWebsiteId();
                         }
                         /** @var $website Mage_Core_Model_Website */
                         $website = $this->storeWebsiteFactory->create()->load($wsId);
                         $defStoreId = $website->getDefaultStore()->getId();
                         $baseTarget = $this->scopeConfig->getValue(\Magento\Framework\UrlInterface::XML_PATH_SECURE_URL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $defStoreId);
                         $baseSource = $this->scopeConfig->getValue(\Magento\Framework\UrlInterface::XML_PATH_SECURE_URL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
                         /** compose redirection URL and replace current base by target base */
                         $urlModel = $this->framework->create();
                         $store = $this->storeStoreFactory->create()->load($defStoreId);
                         $urlModel->setStore($store);
                         $url = $urlModel->getUrl(Praxigento_LoginAs_Config::XMLCFG_ROUTER_FRONT . Praxigento_LoginAs_Config::ROUTE_CUSTOMER_LOGINAS);
                         $url = str_replace($baseSource, $baseTarget, $url);
                         /** compose authentication package */
                         /** @var $authPack Praxigento_LoginAs_Model_Package */
                         $authPack = $this->loginAsPackage;
                         $authPack->setAdminName($operator);
                         $authPack->setCustomerId($customerId);
                         $authPack->setCustomerName($customerName);
                         $authPack->setRedirectUrl($url);
                         $validatorData = $session->getValidatorData();
                         $ip = $validatorData['remote_addr'];
                         $authPack->setIp($ip);
                         /** save login data to file */
                         $authPack->saveAsFile();
                         /** log event */
                         $log = Praxigento_LoginAs_Model_Logger::getLogger($this);
                         $log->trace("Operator '{$operator}' is redirected to front from ip '{$ip}' to login" . " as customer '{$customerName}' ({$customerId}).");
                     }
                     $bu = var_export($this->getLayout()->getUpdate()->getHandles(), true);
                     /** load layout and render blocks */
                     $this->loadLayout()->renderLayout();
                 }
             }
         }
     }
 }
开发者ID:praxigento,项目名称:mage2_ext_login_as,代码行数:60,代码来源:RedirectController.php


示例4: execute

 /**
  * If it's configured to capture on shipment - do this.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $customer = $observer->getEvent()->getCustomer();
     $email = $customer->getEmail();
     $websiteId = $customer->getWebsiteId();
     $customerId = $customer->getEntityId();
     $isSubscribed = $customer->getIsSubscribed();
     try {
         // fix for a multiple hit of the observer
         $emailReg = $this->registry->registry($email . '_customer_save');
         if ($emailReg) {
             return $this;
         }
         $this->registry->register($email . '_customer_save', $email);
         $emailBefore = $this->customerFactory->create()->load($customer->getId())->getEmail();
         $contactModel = $this->contactFactory->create()->loadByCustomerEmail($emailBefore, $websiteId);
         //email change detection
         if ($email != $emailBefore) {
             $this->helper->log('email change detected : ' . $email . ', after : ' . $emailBefore . ', website id : ' . $websiteId);
             $data = ['emailBefore' => $emailBefore, 'email' => $email, 'isSubscribed' => $isSubscribed];
             $this->importerFactory->registerQueue(\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_CONTACT_UPDATE, $data, \Dotdigitalgroup\Email\Model\Importer::MODE_CONTACT_EMAIL_UPDATE, $websiteId);
         } elseif (!$emailBefore) {
             //for new contacts update email
             $contactModel->setEmail($email);
         }
         $contactModel->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED)->setCustomerId($customerId)->save();
     } catch (\Exception $e) {
         $this->helper->debug((string) $e, []);
     }
     return $this;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:38,代码来源:CreateUpdateContact.php


示例5: validate

 /**
  * Validates the fields in a specified address data object.
  *
  * @param \Magento\Quote\Api\Data\AddressInterface $addressData The address data object.
  * @return bool
  * @throws \Magento\Framework\Exception\InputException The specified address belongs to another customer.
  * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer ID or address ID is not valid.
  */
 public function validate(\Magento\Quote\Api\Data\AddressInterface $addressData)
 {
     //validate customer id
     if ($addressData->getCustomerId()) {
         $customer = $this->customerFactory->create();
         $customer->load($addressData->getCustomerId());
         if (!$customer->getId()) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('Invalid customer id %1', $addressData->getCustomerId()));
         }
     }
     // validate address id
     if ($addressData->getId()) {
         $address = $this->quoteAddressFactory->create();
         $address->load($addressData->getId());
         if (!$address->getId()) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('Invalid address id %1', $addressData->getId()));
         }
         // check correspondence between customer id and address id
         if ($addressData->getCustomerId()) {
             if ($address->getCustomerId() != $addressData->getCustomerId()) {
                 throw new \Magento\Framework\Exception\InputException(__('Address with id %1 belongs to another customer', $addressData->getId()));
             }
         }
     }
     return true;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:QuoteAddressValidator.php


示例6: testSave

 /**
  * @param $addressId
  * @param $isDefaultBilling
  * @param $isDefaultShipping
  *
  * @dataProvider getSaveDataProvider
  */
 public function testSave($addressId, $isDefaultBilling, $isDefaultShipping)
 {
     /** @var $customer \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject */
     $customer = $this->getMock('Magento\\Customer\\Model\\Customer', ['__wakeup', 'setDefaultBilling', 'setDefaultShipping', 'save', 'load'], [], '', false);
     $customer->expects($this->any())->method('load')->willReturnSelf();
     $this->customerFactory->expects($this->any())->method('create')->willReturn($customer);
     /** @var $address \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject */
     $address = $this->getMock('Magento\\Customer\\Model\\Address', ['__wakeup', 'getId', 'getEntityTypeId', 'getIsDefaultBilling', 'getIsDefaultShipping', 'hasDataChanges', 'validateBeforeSave', 'beforeSave', 'afterSave', 'isSaveAllowed'], [], '', false);
     $address->expects($this->once())->method('hasDataChanges')->willReturn(true);
     $address->expects($this->once())->method('isSaveAllowed')->willReturn(true);
     $address->expects($this->once())->method('validateBeforeSave');
     $address->expects($this->once())->method('beforeSave');
     $address->expects($this->once())->method('afterSave');
     $address->expects($this->any())->method('getEntityTypeId')->willReturn('3');
     $address->expects($this->any())->method('getId')->willReturn($addressId);
     $address->expects($this->any())->method('getIsDefaultShipping')->willReturn($isDefaultShipping);
     $address->expects($this->any())->method('getIsDefaultBilling')->willReturn($isDefaultBilling);
     if ($addressId && ($isDefaultBilling || $isDefaultShipping)) {
         if ($isDefaultBilling) {
             $customer->expects($this->once())->method('setDefaultBilling')->with($addressId);
         }
         if ($isDefaultShipping) {
             $customer->expects($this->once())->method('setDefaultShipping')->with($addressId);
         }
         $customer->expects($this->once())->method('save');
     } else {
         $customer->expects($this->never())->method('setDefaultBilling');
         $customer->expects($this->never())->method('setDefaultShipping');
         $customer->expects($this->never())->method('save');
     }
     $this->addressResource->setType('customer_address');
     $this->addressResource->save($address);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:40,代码来源:AddressTest.php


示例7: registerWishlist

 /**
  * Automation new wishlist program.
  *
  * @param array $wishlist
  *
  * @return $this
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function registerWishlist($wishlist)
 {
     try {
         $emailWishlist = $this->wishlistFactory->create();
         $customer = $this->customerFactory->create();
         //if wishlist exist not to save again
         if (!$emailWishlist->getWishlist($wishlist['wishlist_id'])) {
             $customer->load($wishlist['customer_id']);
             $email = $customer->getEmail();
             $wishlistId = $wishlist['wishlist_id'];
             $websiteId = $customer->getWebsiteId();
             $emailWishlist->setWishlistId($wishlistId)->setCustomerId($wishlist['customer_id'])->setStoreId($customer->getStoreId())->save();
             $store = $this->storeManager->getStore($customer->getStoreId());
             $storeName = $store->getName();
             //if api is not enabled
             if (!$this->helper->isEnabled($websiteId)) {
                 return $this;
             }
             $programId = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/wishlist_automation', $websiteId);
             //wishlist program mapped
             if ($programId) {
                 $automation = $this->automationFactory->create();
                 //save automation type
                 $automation->setEmail($email)->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_WISHLIST)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($wishlistId)->setWebsiteId($websiteId)->setStoreName($storeName)->setProgramId($programId);
                 $automation->save();
             }
         }
     } catch (\Exception $e) {
         $this->helper->error((string) $e, []);
     }
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:40,代码来源:RegisterWishlist.php


示例8: execute

 /**
  * If it's configured to capture on shipment - do this.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $dataObject = $observer->getEvent()->getDataObject();
     if ($dataObject->getCustomerId() && $dataObject->getStatusId() == \Magento\Review\Model\Review::STATUS_APPROVED) {
         $customerId = $dataObject->getCustomerId();
         $this->helper->setConnectorContactToReImport($customerId);
         //save review info in the table
         $this->registerReview($dataObject);
         $store = $this->storeManager->getStore($dataObject->getStoreId());
         $storeName = $store->getName();
         $website = $this->storeManager->getStore($store)->getWebsite();
         $customer = $this->customerFactory->create()->load($customerId);
         //if api is not enabled
         if (!$this->helper->isEnabled($website)) {
             return $this;
         }
         $programId = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/review_automation');
         if ($programId) {
             $automation = $this->automationFactory->create();
             $automation->setEmail($customer->getEmail())->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_REVIEW)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($dataObject->getReviewId())->setWebsiteId($website->getId())->setStoreName($storeName)->setProgramId($programId);
             $automation->save();
         }
     }
     return $this;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:32,代码来源:ReviewSaveAutomation.php


示例9: getCustomerByEmail

 /**
  * @param string $email
  * @return bool|\Magento\Customer\Model\Customer
  */
 public function getCustomerByEmail($email)
 {
     /** @var \Magento\Customer\Model\Customer $customer */
     $customer = $this->customerFactory->create();
     $customer->setWebsiteId($this->storeManager->getWebsiteId());
     $customer->loadByEmail($email);
     if ($customer->getId()) {
         return $customer;
     }
     return false;
 }
开发者ID:ktplKunj,项目名称:TestMagento,代码行数:15,代码来源:Helper.php


示例10: createCustomer

 public function createCustomer()
 {
     /** @var \Magento\Customer\Model\Customer  $customer */
     $customer = $this->customerFactory->create();
     $customerName = explode(' ', $this->titlesGenerator->generateCustomerName());
     $customer->setFirstname($customerName[0]);
     $customer->setLastname($customerName[1]);
     $customer->setEmail(self::NAMES_PREFIX . uniqid() . '@' . self::DEFAULT_EMAIL_DOMAIN);
     $customer->setWebsiteId($this->storeManager->getWebsite()->getWebsiteId());
     $customer->save($customer);
     return $customer;
 }
开发者ID:rogyar,项目名称:m2-sampledata-generator,代码行数:12,代码来源:CustomersCreator.php


示例11: loadByCustomerId

 public function loadByCustomerId($customerId)
 {
     $this->_customer = $this->_customerFactory->create()->load($customerId);
     if (!$this->_customer->getId()) {
         throw new \Magento\Framework\Exception(__('Could not load by customer id'));
     }
     if (!($socialconnectFid = $this->_customer->getInchooSocialconnectFid()) || !($socialconnectFtoken = $this->_customer->getInchooSocialconnectFtoken())) {
         throw new \Magento\Framework\Exception(__('Could not retrieve token by customer id'));
     }
     $this->setTarget($socialconnectFid);
     $this->setAccessToken($socialconnectFtoken);
     $this->_load();
     return $this;
 }
开发者ID:LavoWeb,项目名称:Magento2-Inchoo_SocialConnect,代码行数:14,代码来源:User.php


示例12: getCustomer

 /**
  * Retrieve customer
  * @return \Magento\Customer\Model\Customer
  */
 public function getCustomer()
 {
     if (is_null($this->_customer)) {
         $this->_customer = $this->_customerFactory->create()->load($this->getCustomerId());
     }
     return $this->_customer;
 }
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:11,代码来源:Login.php


示例13: authenticate

 /**
  * {@inheritdoc}
  */
 public function authenticate($username, $password)
 {
     try {
         switch ($this->advancedLoginConfigProvider->getLoginMode()) {
             case LoginMode::LOGIN_TYPE_ONLY_ATTRIBUTE:
                 $customer = $this->loginViaCustomerAttributeOnly($username);
                 break;
             case LoginMode::LOGIN_TYPE_BOTH:
                 $customer = $this->loginViaCustomerAttributeOrEmail($username);
                 break;
             default:
                 $customer = $this->loginViaEmailOnly($username);
                 break;
         }
     } catch (NoSuchEntityException $e) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     $this->checkPasswordStrength($password);
     $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
     if (!$this->encryptor->validateHash($password, $hash)) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) {
         throw new EmailNotConfirmedException(__('This account is not confirmed.'));
     }
     $customerModel = $this->customerFactory->create()->updateData($customer);
     $this->eventManager->dispatch('customer_customer_authenticated', ['model' => $customerModel, 'password' => $password]);
     $this->eventManager->dispatch('customer_data_object_login', ['customer' => $customer]);
     return $customer;
 }
开发者ID:semaio,项目名称:magento2-advancedlogin,代码行数:33,代码来源:AccountManagement.php


示例14: assignCustomer

 /**
  * {@inheritdoc}
  */
 public function assignCustomer($cartId, $customerId, $storeId)
 {
     $quote = $this->quoteRepository->getActive($cartId);
     $customer = $this->customerRepository->getById($customerId);
     $customerModel = $this->customerModelFactory->create();
     if (!in_array($storeId, $customerModel->load($customerId)->getSharedStoreIds())) {
         throw new StateException(__('Cannot assign customer to the given cart. The cart belongs to different store.'));
     }
     if ($quote->getCustomerId()) {
         throw new StateException(__('Cannot assign customer to the given cart. The cart is not anonymous.'));
     }
     try {
         $this->quoteRepository->getForCustomer($customerId);
         throw new StateException(__('Cannot assign customer to the given cart. Customer already has active cart.'));
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
     }
     $quote->setCustomer($customer);
     $quote->setCustomerIsGuest(0);
     $quoteIdMaskFactory = $this->getQuoteIdMaskFactory();
     /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
     $quoteIdMask = $quoteIdMaskFactory->create()->load($cartId, 'quote_id');
     if ($quoteIdMask->getId()) {
         $quoteIdMask->delete();
     }
     $this->quoteRepository->save($quote);
     return true;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:30,代码来源:QuoteManagement.php


示例15: getCustomer

 /**
  * Retrieve customer model object
  *
  * @return Customer
  * @deprecated use getCustomerId() instead
  */
 public function getCustomer()
 {
     if ($this->_customerModel === null) {
         $this->_customerModel = $this->_customerFactory->create()->load($this->getCustomerId());
     }
     return $this->_customerModel;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:Session.php


示例16: getList

 /**
  * {@inheritdoc}
  */
 public function getList(SearchCriteriaInterface $searchCriteria)
 {
     $searchResults = $this->searchResultsFactory->create();
     $searchResults->setSearchCriteria($searchCriteria);
     /** @var \Magento\Customer\Model\Resource\Customer\Collection $collection */
     $collection = $this->customerFactory->create()->getCollection();
     // This is needed to make sure all the attributes are properly loaded
     foreach ($this->customerMetadata->getAllAttributesMetadata() as $metadata) {
         $collection->addAttributeToSelect($metadata->getAttributeCode());
     }
     // Needed to enable filtering on name as a whole
     $collection->addNameToSelect();
     // Needed to enable filtering based on billing address attributes
     $collection->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')->joinAttribute('company', 'customer_address/company', 'default_billing', null, 'left');
     //Add filters from root filter group to the collection
     foreach ($searchCriteria->getFilterGroups() as $group) {
         $this->addFilterGroupToCollection($group, $collection);
     }
     $searchResults->setTotalCount($collection->getSize());
     $sortOrders = $searchCriteria->getSortOrders();
     if ($sortOrders) {
         foreach ($searchCriteria->getSortOrders() as $sortOrder) {
             $collection->addOrder($sortOrder->getField(), $sortOrder->getDirection() == SearchCriteriaInterface::SORT_ASC ? 'ASC' : 'DESC');
         }
     }
     $collection->setCurPage($searchCriteria->getCurrentPage());
     $collection->setPageSize($searchCriteria->getPageSize());
     $customers = [];
     /** @var \Magento\Customer\Model\Customer $customerModel */
     foreach ($collection as $customerModel) {
         $customers[] = $customerModel->getDataModel();
     }
     $searchResults->setItems($customers);
     return $searchResults;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:38,代码来源:CustomerRepository.php


示例17: testProcessNonceException

 /**
  * @param string $params
  * @dataProvider dataProcessNonce
  */
 public function testProcessNonceException($params = null, $exceptionMessage = null)
 {
     $this->customerSessionMock->expects($this->any())->method('getCustomerId')->willReturn($params['customerId']);
     $countryCollectionMock = $this->getMockBuilder('\\Magento\\Directory\\Model\\Resource\\Country\\Collection')->disableOriginalConstructor()->getMock();
     $countryCollectionMock->expects($this->any())->method('addCountryCodeFilter')->willReturn($countryCollectionMock);
     $this->countryFactoryMock->expects($this->any())->method('create')->willReturn($countryCollectionMock);
     $this->configMock->expects($this->any())->method('canUseForCountry')->willReturn($params['canUseForCountry']);
     $this->configMock->expects($this->any())->method('canUseCcTypeForCountry')->willReturn($params['canUseCcTypeForCountry']);
     $this->helperMock->expects($this->any())->method('generateCustomerId')->willReturn($params['customerId']);
     $this->customerMock->expects($this->any())->method('load')->willReturn($this->customerMock);
     $this->customerFactoryMock->expects($this->any())->method('create')->willReturn($this->customerMock);
     if (is_object($params['paymentMethodObj'])) {
         if (!$params['optionsArray']['update']) {
             $this->braintreePaymentMethodMock->expects($this->once())->method('create')->willReturn($params['paymentMethodObj']);
         } else {
             $this->braintreePaymentMethodMock->expects($this->once())->method('update')->willReturn($params['paymentMethodObj']);
         }
         if (!$params['paymentMethodObj']->success) {
             $this->errorHelperMock->expects($this->once())->method('parseBraintreeError')->willReturn(new \Magento\Framework\Phrase($exceptionMessage));
         } else {
             $this->errorHelperMock->expects($this->never())->method('parseBraintreeError');
         }
     }
     try {
         $this->model->processNonce($params['nonce'], $params['optionsArray'], $params['billingAddress']);
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->assertEquals($exceptionMessage, $e->getMessage());
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:33,代码来源:VaultTest.php


示例18: generateData

 /**
  * @param array $giftRegistryData
  * @return array
  */
 protected function generateData(array $giftRegistryData)
 {
     $giftRegistryData['sku'] = explode("\n", $giftRegistryData['sku']);
     $customer = $this->customerFactory->create();
     $customer->setWebsiteId($this->storeManager->getWebsiteId())->loadByEmail($giftRegistryData['customer_email']);
     $address = $customer->getDefaultBillingAddress()->getData();
     return ['customer_id' => $customer->getId(), 'type_id' => 1, 'title' => $giftRegistryData['title'], 'message' => $giftRegistryData['message'], 'is_public' => 1, 'is_active' => 1, 'event_country' => $address['country_id'], 'event_country_region' => $address['region_id'], 'event_country_region_text' => '', 'event_date' => date('Y-m-d'), 'address' => ['firstname' => $address['firstname'], 'lastname' => $address['lastname'], 'company' => '', 'street' => $address['street'], 'city' => $address['city'], 'region_id' => $address['region_id'], 'region' => $address['region'], 'postcode' => $address['postcode'], 'country_id' => $address['country_id'], 'telephone' => $address['telephone'], 'fax' => ''], 'items' => $this->productSkuToId($giftRegistryData['sku'])];
 }
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:12,代码来源:GiftRegistry.php


示例19: getHeader

 /**
  * Get data for Header section of RSS feed
  *
  * @return array
  */
 public function getHeader()
 {
     $customerId = $this->getWishlist()->getCustomerId();
     $customer = $this->customerFactory->create()->load($customerId);
     $title = __('%1\'s Wishlist', $customer->getName());
     $newUrl = $this->urlBuilder->getUrl('wishlist/shared/index', ['code' => $this->getWishlist()->getSharingCode()]);
     return ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Wishlist.php


示例20: getCustomersWithDuplicateEmails

 /**
  * Number of customers with duplicate emails, emails as total number.
  *
  * @return mixed
  */
 public function getCustomersWithDuplicateEmails()
 {
     $customers = $this->customerFactory->create()->getCollection();
     //duplicate emails
     //@codingStandardsIgnoreStart
     $customers->getSelect()->columns(['emails' => 'COUNT(e.entity_id)'])->group('email')->having('emails > ?', 1);
     //@codingStandardsIgnoreEnd
     return $customers;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:14,代码来源:Data.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Model\Session类代码示例发布时间:2022-05-23
下一篇:
PHP Model\Customer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap