當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::getOptionByCode方法代碼示例

本文整理匯總了PHP中Magento\Quote\Model\Quote\Item::getOptionByCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getOptionByCode方法的具體用法?PHP Item::getOptionByCode怎麽用?PHP Item::getOptionByCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Quote\Model\Quote\Item的用法示例。


在下文中一共展示了Item::getOptionByCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetOptionByCodeNotDeletedCode

 public function testGetOptionByCodeNotDeletedCode()
 {
     $optionCode = 1234;
     $optionMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Item\\Option')->setMethods(['setItem', 'getCode', '__wakeup', 'isDeleted'])->disableOriginalConstructor()->getMock();
     $optionMock->expects($this->once())->method('setItem')->with($this->model)->will($this->returnValue($optionMock));
     $optionMock->expects($this->exactly(3))->method('getCode')->will($this->returnValue($optionCode));
     $optionMock->expects($this->once())->method('isDeleted')->will($this->returnValue(false));
     $this->model->addOption($optionMock);
     $this->assertSame($optionMock, $this->model->getOptionByCode($optionCode));
 }
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例2: getCustomOptions

 /**
  * Get Custom Options of item
  *
  * @param Item $item
  * @return string
  */
 public function getCustomOptions(Item $item)
 {
     $optionStr = '';
     $this->_moveToCustomerStorage = true;
     if ($optionIds = $item->getOptionByCode('option_ids')) {
         foreach (explode(',', $optionIds->getValue()) as $optionId) {
             $option = $item->getProduct()->getOptionById($optionId);
             if ($option) {
                 $optionStr .= $option->getTitle() . ':';
                 $quoteItemOption = $item->getOptionByCode('option_' . $option->getId());
                 $group = $option->groupFactory($option->getType())->setOption($option)->setQuoteItemOption($quoteItemOption);
                 $optionStr .= $group->getEditableOptionValue($quoteItemOption->getValue());
                 $optionStr .= "\n";
             }
         }
     }
     return $optionStr;
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:24,代碼來源:Grid.php

示例3: _prepareOptionsForRequest

 /**
  * Prepare options array for info buy request
  *
  * @param \Magento\Quote\Model\Quote\Item $item
  * @return array
  */
 protected function _prepareOptionsForRequest($item)
 {
     $newInfoOptions = [];
     $optionIds = $item->getOptionByCode('option_ids');
     if ($optionIds) {
         foreach (explode(',', $optionIds->getValue()) as $optionId) {
             $option = $item->getProduct()->getOptionById($optionId);
             $optionValue = $item->getOptionByCode('option_' . $optionId)->getValue();
             $group = $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Option')->groupFactory($option->getType())->setOption($option)->setQuoteItem($item);
             $newInfoOptions[$optionId] = $group->prepareOptionValueForRequest($optionValue);
         }
     }
     return $newInfoOptions;
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:20,代碼來源:Create.php

示例4: buildItemId

 /**
  * @param Item $item
  * @return string
  */
 protected function buildItemId(Item $item)
 {
     /** @var Item $parentItem */
     $parentItem = $item->getOptionByCode('product_type');
     if (!is_null($parentItem)) {
         return $parentItem->getProduct()->getSku();
     } elseif ($item->getProductType() === 'simple') {
         // todo: if the product has a configurable parent and there is "super_attribute" data in the buy request, assume we need to use the parent product SKU, just like in Magento 1.
     }
     return $item->getProduct()->getSku();
 }
開發者ID:Nosto,項目名稱:nosto-magento2,代碼行數:15,代碼來源:Builder.php


注:本文中的Magento\Quote\Model\Quote\Item::getOptionByCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。