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


PHP DataObject::getProduct方法代码示例

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


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

示例1: aroundGetItemQty

 /**
  * Get item qty
  *
  * @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
  * @param callable $proceed
  * @param \Magento\Framework\DataObject $item
  *
  * @return string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundGetItemQty(\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, \Closure $proceed, \Magento\Framework\DataObject $item)
 {
     if ($item->getProduct()->getTypeId() == \Magento\Bundle\Model\Product\Type::TYPE_CODE) {
         return '';
     }
     return $proceed($item);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Sidebar.php

示例2: _toLinkHtml

 /**
  * Render single action as link html
  *
  * @param  array $action
  * @param  \Magento\Framework\DataObject $row
  * @return string|false
  */
 protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
 {
     $product = $row->getProduct();
     if (isset($action['process']) && $action['process'] == 'configurable') {
         if ($product->canConfigure()) {
             $style = '';
             $onClick = sprintf('onclick="return %s.configureItem(%s)"', $action['control_object'], $row->getId());
             return sprintf('<a href="%s" %s %s>%s</a>', $action['url'], $style, $onClick, $action['caption']);
         } else {
             return false;
         }
     } else {
         return parent::_toLinkHtml($action, $row);
     }
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:22,代码来源:Multiaction.php

示例3: updateQtyOption

 /**
  * Can specify specific actions for ability to change given quote options values
  * Example: cataloginventory decimal qty validation may change qty to int,
  * so need to change quote item qty option value.
  *
  * @param \Magento\Framework\DataObject $option
  * @param int|float|null $value
  * @return $this
  */
 public function updateQtyOption(\Magento\Framework\DataObject $option, $value)
 {
     $optionProduct = $option->getProduct();
     $options = $this->getQtyOptions();
     if (isset($options[$optionProduct->getId()])) {
         $options[$optionProduct->getId()]->setValue($value);
     }
     $this->getProduct()->getTypeInstance()->updateQtyOption($this->getOptions(), $option, $value, $this->getProduct());
     return $this;
 }
开发者ID:uibar,项目名称:lavinia2,代码行数:19,代码来源:Item.php

示例4: 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

示例5: isMessagesAllowed

 /**
  * Check if giftmessages is allowed for specified entity.
  *
  * @param string $type
  * @param \Magento\Framework\DataObject $entity
  * @param \Magento\Store\Model\Store|int|null $store
  * @return bool|string|null
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function isMessagesAllowed($type, \Magento\Framework\DataObject $entity, $store = null)
 {
     if ($type == 'items') {
         $items = $entity->getAllItems();
         if (!is_array($items) || empty($items)) {
             return $this->scopeConfig->getValue(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
         }
         if ($entity instanceof \Magento\Quote\Model\Quote) {
             $_type = $entity->getIsMultiShipping() ? 'address_item' : 'item';
         } else {
             $_type = 'order_item';
         }
         foreach ($items as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             if ($this->isMessagesAllowed($_type, $item, $store)) {
                 return true;
             }
         }
     } elseif ($type == 'item') {
         return $this->_getDependenceFromStoreConfig($entity->getProduct()->getGiftMessageAvailable(), $store);
     } elseif ($type == 'order_item') {
         return $this->_getDependenceFromStoreConfig($entity->getGiftMessageAvailable(), $store);
     } elseif ($type == 'address_item') {
         $storeId = is_numeric($store) ? $store : $this->_storeManager->getStore($store)->getId();
         if (!$this->isCached('address_item_' . $entity->getProductId())) {
             try {
                 $giftMessageAvailable = $this->productRepository->getById($entity->getProductId(), false, $storeId)->getGiftMessageAvailable();
             } catch (\Magento\Framework\Exception\NoSuchEntityException $noEntityException) {
                 $giftMessageAvailable = null;
             }
             $this->setCached('address_item_' . $entity->getProductId(), $giftMessageAvailable);
         }
         return $this->_getDependenceFromStoreConfig($this->getCached('address_item_' . $entity->getProductId()), $store);
     } else {
         return $this->scopeConfig->getValue(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
     }
     return false;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:49,代码来源:Message.php


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