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


PHP Item::getParentItem方法代码示例

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


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

示例1: canShipItem

 /**
  * Checks if order item can be shipped.
  *
  * Dummy item can be shipped or with his children or
  * with parent item which is included to shipment.
  *
  * @param \Magento\Sales\Model\Order\Item $item
  * @param array $items
  * @return bool
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function canShipItem($item, array $items = [])
 {
     if ($item->getIsVirtual() || $item->getLockedDoShip()) {
         return false;
     }
     if ($item->isDummy(true)) {
         if ($item->getHasChildren()) {
             if ($item->isShipSeparately()) {
                 return true;
             }
             foreach ($item->getChildrenItems() as $child) {
                 if ($child->getIsVirtual()) {
                     continue;
                 }
                 if (empty($items)) {
                     if ($child->getQtyToShip() > 0) {
                         return true;
                     }
                 } else {
                     if (isset($items[$child->getId()]) && $items[$child->getId()] > 0) {
                         return true;
                     }
                 }
             }
             return false;
         } elseif ($item->getParentItem()) {
             $parent = $item->getParentItem();
             if (empty($items)) {
                 return $parent->getQtyToShip() > 0;
             } else {
                 return isset($items[$parent->getId()]) && $items[$parent->getId()] > 0;
             }
         }
     } else {
         return $item->getQtyToShip() > 0;
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:48,代码来源:ShipmentFactory.php

示例2: testGetPatentItem

 public function testGetPatentItem()
 {
     $item = $this->objectManager->getObject('Magento\\Sales\\Model\\Order\\Item', []);
     $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::PARENT_ITEM, $item);
     $this->assertEquals($item, $this->model->getParentItem());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:6,代码来源:ItemTest.php

示例3: addOrderItem

 /**
  * Convert order item to quote item
  *
  * @param \Magento\Sales\Model\Order\Item $orderItem
  * @param true|null $qtyFlag if is null set product qty like in order
  * @return $this
  */
 public function addOrderItem($orderItem, $qtyFlag = null)
 {
     /* @var $orderItem \Magento\Sales\Model\Order\Item */
     if ($orderItem->getParentItem() === null) {
         $storeId = $this->_storeManager->getStore()->getId();
         try {
             $product = $this->productRepository->getById($orderItem->getProductId(), false, $storeId);
         } catch (NoSuchEntityException $e) {
             return $this;
         }
         $info = $orderItem->getProductOptionByCode('info_buyRequest');
         $info = new \Magento\Framework\Object($info);
         if ($qtyFlag === null) {
             $info->setQty($orderItem->getQtyOrdered());
         } else {
             $info->setQty(1);
         }
         $this->addProduct($product, $info);
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:Cart.php

示例4: _canRefundItem

 /**
  * Check if order item can be refunded
  *
  * @param \Magento\Sales\Model\Order\Item $item
  * @param array $qtys
  * @param array $invoiceQtysRefundLimits
  * @return bool
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _canRefundItem($item, $qtys = [], $invoiceQtysRefundLimits = [])
 {
     if ($item->isDummy()) {
         if ($item->getHasChildren()) {
             foreach ($item->getChildrenItems() as $child) {
                 if (empty($qtys)) {
                     if ($this->_canRefundNoDummyItem($child, $invoiceQtysRefundLimits)) {
                         return true;
                     }
                 } else {
                     if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) {
                         return true;
                     }
                 }
             }
             return false;
         } elseif ($item->getParentItem()) {
             $parent = $item->getParentItem();
             if (empty($qtys)) {
                 return $this->_canRefundNoDummyItem($parent, $invoiceQtysRefundLimits);
             } else {
                 return isset($qtys[$parent->getId()]) && $qtys[$parent->getId()] > 0;
             }
         }
     } else {
         return $this->_canRefundNoDummyItem($item, $invoiceQtysRefundLimits);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:Order.php

示例5: addOrderItem

 /**
  * Convert order item to quote item
  *
  * @param \Magento\Sales\Model\Order\Item $orderItem
  * @param true|null $qtyFlag if is null set product qty like in order
  * @return $this
  */
 public function addOrderItem($orderItem, $qtyFlag = null)
 {
     /* @var $orderItem \Magento\Sales\Model\Order\Item */
     if (is_null($orderItem->getParentItem())) {
         $product = $this->_productFactory->create()->setStoreId($this->_storeManager->getStore()->getId())->load($orderItem->getProductId());
         if (!$product->getId()) {
             return $this;
         }
         $info = $orderItem->getProductOptionByCode('info_buyRequest');
         $info = new \Magento\Framework\Object($info);
         if (is_null($qtyFlag)) {
             $info->setQty($orderItem->getQtyOrdered());
         } else {
             $info->setQty(1);
         }
         $this->addProduct($product, $info);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:26,代码来源:Cart.php

示例6: addOrderItem

 /**
  * Convert order item to quote item
  *
  * @param \Magento\Sales\Model\Order\Item $orderItem
  * @param true|null $qtyFlag if is null set product qty like in order
  * @return $this
  */
 public function addOrderItem($orderItem, $qtyFlag = null)
 {
     /* @var $orderItem \Magento\Sales\Model\Order\Item */
     if ($orderItem->getParentItem() === null) {
         $storeId = $this->_storeManager->getStore()->getId();
         try {
             /**
              * We need to reload product in this place, because products
              * with the same id may have different sets of order attributes.
              */
             $product = $this->productRepository->getById($orderItem->getProductId(), false, $storeId, true);
         } catch (NoSuchEntityException $e) {
             return $this;
         }
         $info = $orderItem->getProductOptionByCode('info_buyRequest');
         $info = new \Magento\Framework\DataObject($info);
         if ($qtyFlag === null) {
             $info->setQty($orderItem->getQtyOrdered());
         } else {
             $info->setQty(1);
         }
         $this->addProduct($product, $info);
     }
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:32,代码来源:Cart.php


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