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


PHP Object::getCode方法代碼示例

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


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

示例1: updateQtyOption

 /**
  * Method is needed for specific actions to change given quote options values
  * according current product type logic
  * Example: the catalog inventory validation of decimal qty can change qty to int,
  * so need to change quote item qty option value too.
  *
  * @param   array           $options
  * @param   \Magento\Framework\Object   $option
  * @param   mixed           $value
  * @param   \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function updateQtyOption($options, \Magento\Framework\Object $option, $value, $product)
 {
     $optionProduct = $option->getProduct($product);
     $optionUpdateFlag = $option->getHasQtyOptionUpdate();
     $optionCollection = $this->getOptionsCollection($product);
     $selections = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
     foreach ($selections as $selection) {
         if ($selection->getProductId() == $optionProduct->getId()) {
             foreach ($options as &$option) {
                 if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) {
                     if ($optionUpdateFlag) {
                         $option->setValue(intval($option->getValue()));
                     } else {
                         $option->setValue($value);
                     }
                 }
             }
         }
     }
     return $this;
 }
開發者ID:zhangjiachao,項目名稱:magento2,代碼行數:33,代碼來源:Type.php

示例2: addTotalBefore

 /**
  * Add new total to totals array before specific total or after first total by default
  *
  * @param   \Magento\Framework\Object $total
  * @param   null|string $before
  * @return  $this
  */
 public function addTotalBefore(\Magento\Framework\Object $total, $before = null)
 {
     if ($before !== null) {
         if (!is_array($before)) {
             $before = array($before);
         }
         foreach ($before as $beforeTotals) {
             if (isset($this->_totals[$beforeTotals])) {
                 $totals = array();
                 foreach ($this->_totals as $code => $item) {
                     if ($code == $beforeTotals) {
                         $totals[$total->getCode()] = $total;
                     }
                     $totals[$code] = $item;
                 }
                 $this->_totals = $totals;
                 return $this;
             }
         }
     }
     $totals = array();
     $first = array_shift($this->_totals);
     $totals[$first->getCode()] = $first;
     $totals[$total->getCode()] = $total;
     foreach ($this->_totals as $code => $item) {
         $totals[$code] = $item;
     }
     $this->_totals = $totals;
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:37,代碼來源:Totals.php

示例3: renderShippingRateValue

 /**
  * Get either shipping rate code or empty value on error
  *
  * @param \Magento\Framework\Object $rate
  * @return string
  */
 public function renderShippingRateValue(\Magento\Framework\Object $rate)
 {
     if ($rate->getErrorMessage()) {
         return '';
     }
     return $rate->getCode();
 }
開發者ID:zhangjiachao,項目名稱:magento2,代碼行數:13,代碼來源:Review.php


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