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


PHP Customer::load方法代码示例

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


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

示例1: beforeSubscribeCustomerById

 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMageiaEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         /*
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn()
             && $this->_customerSession->getCustomerDataObject()->getEmail()
             == $subscriber->getSubscriberEmail();
         
         if ($this->_helper->isDoubleOptInEnabled($storeId)
             && !$isSubscribeOwnEmail
         ) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         */
         $email = ['email' => $customer->getEmail()];
         if ($mergeVars) {
             $email['variables'] = $mergeVars;
         }
         $data = ['emails' => json_encode([$email])];
         $listId = $this->_helper->getDefaultList();
         $return = $api->listCreateMember($listId, $data);
         if (isset($return->result) && $return->result) {
             $subscriber->setMageiaId($customer->getEmail());
             $subscriber->save();
         }
     }
     return [$customerId];
 }
开发者ID:sendpulse,项目名称:mageia,代码行数:35,代码来源:Plugin.php

示例2: beforeSubscribeCustomerById

 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         if ($mergeVars) {
             $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars);
         } else {
             $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status);
         }
         $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
         if (isset($return->id)) {
             $subscriber->setMagemonkeyId($return->id);
         }
     }
     return [$customerId];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:Subscriber.php

示例3: setUp

 /**
  * Initialize quote and customer fixtures
  */
 public function setUp()
 {
     $this->_quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote');
     $this->_quote->load('test01', 'reserved_order_id');
     $this->_quote->setIsMultiShipping('0');
     /** @var \Magento\Customer\Model\Customer $customer */
     $this->_customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Customer');
     $this->_customer->load(1);
     /** @var \Magento\Sales\Model\Order\Address $address */
     $this->_address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote\\Address');
     $this->_address->load(1);
     $this->_address->setQuote($this->_quote);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:AddressTest.php

示例4: afterSubscribeCustomerById

 public function afterSubscribeCustomerById($subscriber)
 {
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($subscriber->getCustomerId());
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = new \Ebizmarts\MageMonkey\Model\Api(array(), $this->_helper);
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $subscriber->getEmail(), 'email_type' => 'html', 'status' => $status);
         $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
         if (isset($return->id)) {
             $subscriber->setMagemonkeyId($return->id)->save();
         }
     }
 }
开发者ID:andrewkett,项目名称:magento2-magemonkey,代码行数:20,代码来源:Subscriber.php

示例5: beforeSubscribeCustomerById

 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $subscriber->setImportMode(true);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         if ($mergeVars) {
             $data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars];
         } else {
             $data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => ['EMAIL' => $customer->getEmail()]];
         }
         try {
             $emailHash = md5(strtolower($customer->getEmail()));
             $return = $api->getMember($this->_helper->getDefaultList(), $emailHash);
             if (!isset($return->id)) {
                 $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
                 if (isset($return->id)) {
                     $subscriber->setMagemonkeyId($return->id)->save();
                 }
             }
             $subscriber->setMagemonkeyId($emailHash)->save();
         } catch (\Exception $e) {
             $this->_helper->log($e->getMessage());
         }
     }
     return [$customerId];
 }
开发者ID:ebizmarts,项目名称:magento2-magemonkey,代码行数:36,代码来源:Subscriber.php

示例6: getCustomer

 /**
  * Retrieve customer model object
  *
  * @return \Magento\Customer\Model\Customer
  */
 public function getCustomer()
 {
     /**
      * @TODO: Remove the method after all external usages are refactored in MAGETWO-19930
      * _customer and _customerFactory variables should be eliminated as well
      */
     if (null === $this->_customer) {
         $this->_customer = $this->_customerFactory->create();
         $customerId = $this->getCustomerId();
         if ($customerId) {
             $this->_customer->load($customerId);
             if (!$this->_customer->getId()) {
                 $this->_customer->setCustomerId(null);
             }
         }
     }
     return $this->_customer;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:23,代码来源:Quote.php


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