本文整理汇总了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;
}
示例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);
}