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


PHP Session::setCustomerData方法代码示例

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


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

示例1: testGetQuoteNotInitializedCustomerSet

 /**
  * Test covers case when quote is not yet initialized and customer data is set to checkout session model.
  *
  * Expected result - quote object should be loaded and customer data should be set to it.
  *
  * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
  */
 public function testGetQuoteNotInitializedCustomerSet()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
     $customerRepository = $objectManager->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $customer = $customerRepository->getById(1);
     $this->_checkoutSession->setCustomerData($customer);
     /** Execute SUT */
     $quote = $this->_checkoutSession->getQuote();
     $this->_validateCustomerDataInQuote($quote);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:18,代码来源:SessionTest.php

示例2: testGetQuoteNotInitializedCustomerSet

 /**
  * Test covers case when quote is not yet initialized and customer data is set to checkout session model.
  *
  * Expected result - quote object should be loaded and customer data should be set to it.
  *
  * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
  */
 public function testGetQuoteNotInitializedCustomerSet()
 {
     /** Preconditions */
     $customerIdFromFixture = 1;
     /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService */
     $customerService = Bootstrap::getObjectManager()->get('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
     $customer = $customerService->getCustomer($customerIdFromFixture);
     $this->_checkoutSession->setCustomerData($customer);
     /** Execute SUT */
     $quote = $this->_checkoutSession->getQuote();
     $this->_validateCustomerDataInQuote($quote);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:SessionTest.php

示例3: execute

 /**
  * Emulate quote by persistent data
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute($observer)
 {
     $stopActions = ['persistent_index_saveMethod', 'customer_account_createpost'];
     if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) {
         return;
     }
     $actionName = $observer->getEvent()->getRequest()->getFullActionName();
     if (in_array($actionName, $stopActions)) {
         return;
     }
     if ($this->_persistentData->isShoppingCartPersist()) {
         $this->_checkoutSession->setCustomerData($this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId()));
         if (!$this->_checkoutSession->hasQuote()) {
             $this->_checkoutSession->getQuote();
         }
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:EmulateQuote.php

示例4: expire

 /**
  * Expire persistent quote
  *
  * @return void
  */
 public function expire()
 {
     $quote = $this->checkoutSession->setLoadInactive()->getQuote();
     if ($quote->getIsActive() && $quote->getCustomerId()) {
         $this->checkoutSession->setCustomerData(null)->clearQuote()->clearStorage();
     } else {
         $quote->setIsActive(true)->setIsPersistent(false)->setCustomerId(null)->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:QuoteManager.php

示例5: _expirePersistentSession

 /**
  * @return void
  */
 protected function _expirePersistentSession()
 {
     $quote = $this->_checkoutSession->setLoadInactive()->getQuote();
     if ($quote->getIsActive() && $quote->getCustomerId()) {
         $this->_checkoutSession->setCustomerData(null)->clearQuote()->clearStorage();
     } else {
         $quote->setIsActive(true)->setIsPersistent(false)->setCustomerId(null)->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Observer.php


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