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


PHP DataObject::getCode方法代码示例

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


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

示例1: renderShippingRateValue

 /**
  * Get either shipping rate code or empty value on error
  *
  * @param \Magento\Framework\DataObject $rate
  * @return string
  */
 public function renderShippingRateValue(\Magento\Framework\DataObject $rate)
 {
     if ($rate->getErrorMessage()) {
         return '';
     }
     return $rate->getCode();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:13,代码来源:Review.php

示例2: 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\DataObject $option
  * @param   mixed $value
  * @param   \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function updateQtyOption($options, \Magento\Framework\DataObject $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:rafaelstz,项目名称:magento2,代码行数:33,代码来源:Type.php

示例3: addTotalBefore

 /**
  * Add new total to totals array before specific total or after first total by default
  *
  * @param   \Magento\Framework\DataObject $total
  * @param   null|string $before
  * @return  $this
  */
 public function addTotalBefore(\Magento\Framework\DataObject $total, $before = null)
 {
     if ($before !== null) {
         if (!is_array($before)) {
             $before = [$before];
         }
         foreach ($before as $beforeTotals) {
             if (isset($this->_totals[$beforeTotals])) {
                 $totals = [];
                 foreach ($this->_totals as $code => $item) {
                     if ($code == $beforeTotals) {
                         $totals[$total->getCode()] = $total;
                     }
                     $totals[$code] = $item;
                 }
                 $this->_totals = $totals;
                 return $this;
             }
         }
     }
     $totals = [];
     $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:pradeep-wagento,项目名称:magento2,代码行数:37,代码来源:Totals.php


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