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


PHP Quote::setWebsite方法代码示例

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


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

示例1: _initData

 /**
  * Loads customer, quote and quote item by request params
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _initData()
 {
     $this->_customerId = (int) $this->getRequest()->getParam('customer_id');
     if (!$this->_customerId) {
         throw new \Magento\Framework\Exception\LocalizedException(__('No customer ID defined.'));
     }
     $quoteItemId = (int) $this->getRequest()->getParam('id');
     $websiteId = (int) $this->getRequest()->getParam('website_id');
     try {
         $this->_quote = $this->quoteRepository->getForCustomer($this->_customerId);
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         $this->_quote = $this->quoteRepository->create();
     }
     $this->_quote->setWebsite($this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getWebsite($websiteId));
     $this->_quoteItem = $this->_quote->getItemById($quoteItemId);
     if (!$this->_quoteItem) {
         throw new LocalizedException(__('Please correct the quote items and try again.'));
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:Cart.php

示例2: testGetSharedWebsiteStoreIds

 public function testGetSharedWebsiteStoreIds()
 {
     $sharedIds = null;
     $storeIds = [1, 2, 3];
     $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $websiteMock->expects($this->once())->method('getStoreIds')->will($this->returnValue($storeIds));
     $this->quote->setData('shared_store_ids', $sharedIds);
     $this->quote->setWebsite($websiteMock);
     $result = $this->quote->getSharedStoreIds();
     $this->assertEquals($storeIds, $result);
 }
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:QuoteTest.php


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