/** * Check item product availability for reorder * * @param Mage_Sales_Model_Order_Item $orderItem * @return boolean */ public function isItemAvailableForReorder(Mage_Sales_Model_Order_Item $orderItem) { if ($orderItem->getProduct()) { return $orderItem->getProduct()->getStockItem()->getIsInStock(); } return false; }
public function getItemHtml(Mage_Sales_Model_Order_Item $item) { $warehouseData = $this->getWarehouseFlatArray(); $html = ''; $children = $item->getChildrenItems(); if (empty($children)) { $children = array($item); } /** @var Mage_Sales_Model_Order_Item $childItem */ foreach ($children as $childItem) { $serializedAdditionalData = $childItem->getAdditionalData(); if (empty($serializedAdditionalData)) { continue; } $additionalData = unserialize($serializedAdditionalData); $tmpHtml = sprintf('<tr class="border"><td><strong>%s</strong><br/><strong>SKU:</strong> %s</td>', $childItem->getName(), $childItem->getSku()); $tmpCount = 0; foreach ($warehouseData as $wid => $wdata) { $qty = 0; if (array_key_exists($wid, $additionalData)) { $qty = $additionalData[$wid]; } $tmpCount += $qty; $qty = $this->_formatQty($qty, $childItem->getIsQtyDecimal()); $tmpHtml .= '<td class="a-center" style="vertical-align:middle;">' . $qty . '</td>'; } if ($tmpCount) { $html .= $tmpHtml; } $html .= '</tr>'; } return $html; }
/** * @param array $args Must contain key/values for: * - item => Mage_Sales_Model_Order_Item * - tax_records => EbayEnterprise_Tax_Model_Record[] * - order_item_payload => eBayEnterprise\RetailOrderManagement\Payload\Order\IOrderItem * May contain key/values for: * - logger => EbayEnterprise_MageLog_Helper_Data * - log_context => EbayEnterprise_MageLog_Helper_Context * - payload_helper => EbayEnterprise_Tax_Helper_Payload * - tax_config => EbayEnterprise_Eb2cCore_Model_Config_Registry * - fees => EbayEnterprise_Tax_Model_Fee[] * - duty => EbayEnterprise_Tax_Model_Duty */ public function __construct(array $args = []) { list($this->_item, $this->_taxRecords, $this->_orderItemPayload, $this->_logger, $this->_logContext, $this->_payloadHelper, $this->_taxConfig, $this->_fees, $this->_duty) = $this->_checkTypes($args['item'], $args['tax_records'], $args['order_item_payload'], $this->_nullCoalesce($args, 'logger', Mage::helper('ebayenterprise_magelog')), $this->_nullCoalesce($args, 'log_context', Mage::helper('ebayenterprise_magelog/context')), $this->_nullCoalesce($args, 'payload_helper', Mage::helper('ebayenterprise_tax/payload')), $this->_nullCoalesce($args, 'tax_config', Mage::helper('ebayenterprise_tax')->getConfigModel()), $this->_nullCoalesce($args, 'fees', []), $this->_nullCoalesce($args, 'duty', null)); $this->_indexTaxRecords(); // The order item *should* already have the associated product entity // loaded but if it doesn't, load the product using the product id of the item. $this->_itemProduct = $this->_item->getProduct() ?: Mage::getModel('catalog/product')->load($this->_item->getProductId()); }
/** * Initialize block with order item * * @param Mage_Sales_Model_Order_Item $item * @return SSE_EditCustomOptions_Block_Options */ public function init(Mage_Sales_Model_Order_Item $item) { $this->_item = $item; $_product = $this->_item->getProduct(); Mage::helper('catalog/product')->prepareProductOptions($_product, $this->_getBuyRequest()); $this->addOptionRenderer('text', 'catalog/product_view_options_type_text', 'catalog/product/view/options/type/text.phtml')->addOptionRenderer('file', 'catalog/product_view_options_type_file', 'catalog/product/view/options/type/file.phtml')->addOptionRenderer('select', 'catalog/product_view_options_type_select', 'catalog/product/view/options/type/select.phtml')->addOptionRenderer('date', 'catalog/product_view_options_type_date', 'catalog/product/view/options/type/date.phtml')->setTemplate('catalog/product/view/options.phtml')->setProduct($_product); return $this; }
/** * Set item * * @param Mage_Sales_Model_Order_Item $item * @return Uecommerce_Mundipagg_Model_Recurrency */ public function setItem(Mage_Sales_Model_Order_Item $item) { $this->_item = $item; $this->_product = Mage::getModel('catalog/product')->load($item->getProductId()); if ($this->_product->getMundipaggRecurrent() && $this->isRecurrent()) { $this->_setRecurrencyByProduct($this->_product); } return $this; }
/** * get allocation information for an item * * @param Mage_Sales_Model_Order_Item * @return EbayEnterprise_Inventory_Model_Allocation|null */ public function getItemAllocationInformation(Mage_Sales_Model_Order_Item $item) { $result = $this->getInventorySession()->getAllocationResult(); if ($result) { return $result->lookupAllocationByItemId($item->getQuoteItemId()); } $this->logger->debug('Unable to get allocation information for item {sku} id {item_id}', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku(), 'item_id' => $item->getQuoteItemId()])); return null; }
/** * Get names of second level categories for ordered item * * @item Mage_Sales_Model_Order_Item * @return string */ public function getProductTypeByOrderItem(Mage_Sales_Model_Order_Item $item) { $ret = null; if ($item->getProductId() && ($_product = Mage::getModel('catalog/product')->load($item->getProductId()))) { /* @var $_product Gorilla_Catalog_Model_Product */ if ($typeId = $_product->getItemType()) { $ret = $_product->getResource()->getAttribute("item_type")->getSource()->getOptionText($typeId); } } return $ret; }
/** * When I try to transfer discounts from a sales object to payloads * and the discount node exists in an address * then the returned IDiscountContainer will have one discount. */ public function testTransferDiscounts() { $this->_item->setEbayEnterpriseOrderDiscountData(['1' => ['id' => '1']]); $discountHelper = Mage::helper('eb2ccore/discount'); $discountHelper->transferDiscounts($this->_item, $this->_payload); $discounts = $this->_payload->getDiscounts(); $this->assertCount(1, $discounts); $discounts->rewind(); $discount = $discounts->current(); $this->assertSame('1', $discount->getId()); }
/** * Get a default address for an item if one exists. For virtual items, * the default address will be the billing address of the order the item * belongs to. For non-virtual items, the default address will be the * primary shipping address of the order the item belongs to. If the * appropriate default address for the item does not exits, no address * will be returned. * * @param Mage_Sales_Model_Order_Item * @return Mage_Sales_Model_Order_Address|null */ protected function _loadDefaultAddressForItem(Mage_Sales_Model_Order_Item $item) { $order = $item->getOrder(); if (!$order) { return null; } $defaultAddress = $item->getIsVirtual() ? $order->getBillingAddress() : $order->getShippingAddress(); // If the appropriate default address did not exist in the order, false // will have been returned. In such cases, return null to indicate that // no such address exists. return $defaultAddress ?: null; }
protected function getKwixoCategoryFromOrderItem(Mage_Sales_Model_Order_Item $item) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); $kwixoCategoryId = null; foreach ($product->getCategoryIds() as $categoryId) { $kwixoCategory = Mage::getModel('ops/kwixo_category_mapping')->loadByCategoryId($categoryId); if (!is_null($kwixoCategory->getId())) { $kwixoCategoryId = $kwixoCategory->getKwixoCategoryId(); break; } } return $kwixoCategoryId; }
/** * Return custom options from item * * @see Mage_Sales_Block_Order_Item_Renderer_Default::getItemOptions() * @return array */ protected function _getItemOptions(Mage_Sales_Model_Order_Item $item) { $result = array(); if ($options = $item->getProductOptions()) { if (isset($options['options'])) { $result = array_merge($result, $options['options']); } if (isset($options['additional_options'])) { $result = array_merge($result, $options['additional_options']); } if (isset($options['attributes_info'])) { $result = array_merge($result, $options['attributes_info']); } } return $result; }
protected function _construct() { parent::_construct(); // an item must have a valid product id in order for the // reorder link to work see Mage_Sales_Model_Order::_canReorder method if (!$this->getProductId()) { $this->setProductId(Mage::getModel('catalog/product')->getIdBySku($this->getSku())); } }
public static function crateFromOrderItem(Mage_Sales_Model_Order_Item $orderItem) { $productId = $orderItem->getProductId(); /** @var Mage_Catalog_Model_Product $product */ $product = Mage::getModel('catalog/product')->load($productId); $discounts = $product->getPrice() - $product->getFinalPrice(); $aArticle = new self(); $aArticle->id = $productId; $aArticle->name = $orderItem->getName(); $aArticle->url = $product->getProductUrl(); $aArticle->image_url = $product->getImageUrl(); $aArticle->quantity = intval($orderItem->getQtyOrdered()); $aArticle->price = Aplazame_Sdk_Serializer_Decimal::fromFloat($orderItem->getPrice() + $discounts); $aArticle->description = substr($product->getDescription(), 0, 255); $aArticle->tax_rate = Aplazame_Sdk_Serializer_Decimal::fromFloat(self::getProductTaxRate($product)); $aArticle->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat($discounts); return $aArticle; }
/** * Ensure id of the order address the item is associated with is saved. * * @return self */ protected function _beforeSave() { parent::_beforeSave(); $orderAddress = $this->getOrderAddress(); if ($orderAddress) { $this->setOrderAddressId($orderAddress->getId()); } return $this; }
/** * Convert order item to quote item * * @param Mage_Sales_Model_Order_Item $orderItem * @param mixed $qtyFlag if is null set product qty like in order * @return Mage_Checkout_Model_Cart */ public function addOrderItem($orderItem, $qtyFlag = null) { /* @var $orderItem Mage_Sales_Model_Order_Item */ if (is_null($orderItem->getParentItem())) { $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($orderItem->getProductId()); if (!$product->getId()) { return $this; } $info = $orderItem->getProductOptionByCode('info_buyRequest'); $info = new Varien_Object($info); if (is_null($qtyFlag)) { $info->setQty($orderItem->getQtyOrdered()); } else { $info->setQty(1); } $this->addProduct($product, $info); } return $this; }
/** * Initialize creation data from existing order Item * * @param Mage_Sales_Model_Order_Item $orderItem * @param int $qty * @return Mage_Sales_Model_Quote_Item | string */ public function initFromOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = null) { if (!$orderItem->getId()) { return $this; } $product = Mage::getModel('catalog/product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId()); if ($product->getId()) { $product->setSkipCheckRequiredOption(true); $buyRequest = $orderItem->getBuyRequest(); if (is_numeric($qty)) { $buyRequest->setQty($qty); } $item = $this->getQuote()->addProduct($product, $buyRequest); if (is_string($item)) { return $item; } /*********************************************Set custom price selected starts************************************************************/ if (!$this->getSession()->getReordered() && $orderItem->getOriginalPrice() != $orderItem->getPrice()) { if ($orderItem->getProductType() == 'configurable' || $orderItem->getProductType() == 'bundle') { $productId = $orderItem->getProductId(); $quoteItemId = $orderItem->getQuoteItemId(); $items = $this->getQuote()->getItemsCollection(); foreach ($items as $item) { if ($item->getProduct()->getId() == $productId && !$item->getApplyPriceFlag()) { if ($orderItem->getOriginalPrice() != $orderItem->getPrice()) { $item->setCustomPrice($orderItem->getPrice())->setOriginalCustomPrice($orderItem->getPrice()); } //$item->setApplyPriceFlag(true); } } } else { $item->setCustomPrice($orderItem->getPrice())->setOriginalCustomPrice($orderItem->getPrice()); } } /*********************************************Set custom price selected ends************************************************************/ if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) { $item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions)))); } Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item)); return $item; } return $this; }
public function getOptions(Mage_Sales_Model_Order_Item $item) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); $optionCode = $this->getOptionCode($product); if (isset($product) && $product->getId()) { $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product); $sizes = array(); foreach ($childProducts as $child) { $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($child)->getQty(); if ($qtyStock > 0) { $sizes[$child->getId()] = $child->getResource()->getAttribute($optionCode)->getSource()->getOptionText($child->getData($optionCode)); } } } if (isset($sizes) && count($sizes) > 0) { return $sizes; } else { return false; } }
/** * when saving, update supply needs for product (if concerned) * */ protected function _afterSave() { parent::_afterSave(); //If reserved qty change, update order planning $reservedQtyChanged = $this->getreserved_qty() != $this->getOrigData('reserved_qty'); $qtyToShip = $this->getqty_ordered() - $this->getRealShippedQty() - $this->getqty_canceled() - $this->getqty_refunded(); if ($reservedQtyChanged && $qtyToShip > 0) { //add a task to update order planning $orderId = $this->getorder_id(); mage::helper('BackgroundTask')->AddTask('Update planning for order ' . $orderId, 'purchase/Planning', 'updatePlanning', $orderId); } return $this; }
public function renderSerialOptionOnOrderItem(Mage_Sales_Model_Order_Item $orderItem, $noSerialsAvailableMessage = null, $checkIfSerialRequired = false) { if ($checkIfSerialRequired) { $product = Mage::getModel('catalog/product')->load($orderItem->getProductId()); if (!$product->getSerialRequired()) { return $this; } } if (is_null($noSerialsAvailableMessage)) { $noSerialsAvailableMessage = self::DEFAULT_MISSING_SERIAL_MESSAGE; } $downloadableCollection = Mage::getModel('ecodes/downloadable')->getCollection(); $assignedSerials = $downloadableCollection->getAssignedSerials($orderItem); $order = Mage::getModel('sales/order')->load($orderItem->getOrderId()); if ($order->getVolumeLicense() != 0 && $order->getParentOrderId() == NULL) { $noSerialsAvailableMessage = self::SERIALS_VOLUME_LICENSE_PARENT_ORDER_MESSAGE; } $orderItemProductOptions = $orderItem->getProductOptions(); $value = $assignedSerials ? implode(',', $assignedSerials) : $noSerialsAvailableMessage; $orderItemProductOptions['options']['ecodes_downloadable_serials']['label'] = 'Assigned Serials'; $orderItemProductOptions['options']['ecodes_downloadable_serials']['value'] = $value; $orderItem->setProductOptions($orderItemProductOptions); return $this; }
/** * When adding gift pricing to an item, amount should be wrap price * qty * (handled by the helper method) and unit price should be just the gift * wrapping price. */ public function testAddGiftPricingItem() { $wrapPrice = 10.0; $qty = 2; $giftPrice = $qty * $wrapPrice; // Assume this method will return the proper amount for for the total // amount for gift pricing. $this->_helperMock->expects($this->any())->method('calculateGwItemRowTotal')->with($this->identicalTo($this->_item))->will($this->returnValue($giftPrice)); $this->_item->addData(array('gw_price' => $wrapPrice, 'qty' => $qty)); $payload = $this->_orderCreateRequest->getShipGroups()->getEmptyShipGroup(); $gifting = Mage::getModel('eb2cgiftwrap/order_create_gifting', array('helper' => $this->_helperMock)); $gifting->injectGifting($this->_item, $payload); $this->assertSame($giftPrice, $payload->getGiftPricing()->getAmount()); $this->assertSame($wrapPrice, $payload->getGiftPricing()->getUnitPrice()); }
/** * Loads all relevant product and category data for the item * * @param Mage_Sales_Model_Order_Item|Mage_Sales_Model_Quote_Item $item * @param int $orderStoreId * @param int $websiteId * @param int $maxLimit */ public function loadCatalogData($item, $storeId, $websiteId, $maxLimit = 10) { $product = null; $categories = array(); $related = array(); $upsells = array(); // load product details if ($item->getProductId()) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); // deleted if (!$product->getId()) { $product = null; } if ($product) { $relatedCollection = $product->getRelatedProductCollection()->addAttributeToSelect('name')->addAttributeToSelect('sku')->addAttributeToSelect('url_path')->addAttributeToSelect('image')->addAttributeToSelect('visibility')->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setPageSize($maxLimit); foreach ($relatedCollection as $p) { $websiteIds = $p->getWebsiteIds(); if (in_array($websiteId, $websiteIds)) { $related[$p->getId()] = $this->convertAttributeData($p); } } $upsellCollection = $product->getUpSellProductCollection()->addAttributeToSelect('name')->addAttributeToSelect('sku')->addAttributeToSelect('url_path')->addAttributeToSelect('image')->addAttributeToSelect('visibility')->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setPageSize($maxLimit); foreach ($upsellCollection as $p) { $websiteIds = $p->getWebsiteIds(); if (in_array($websiteId, $websiteIds)) { $upsells[$p->getId()] = $this->convertAttributeData($p); } } $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name')->addAttributeToSelect('is_active')->addAttributeToSelect('url_path')->addAttributeToFilter('level', array('gt' => 1))->setPageSize($maxLimit); foreach ($categoryCollection as $category) { $storeIds = $category->getStoreIds(); if (in_array($storeId, $storeIds)) { $categories[$category->getId()] = $this->convertAttributeData($category); } } $product->setRelatedProducts($related); $product->setUpSellProducts($upsells); } $item->setData('product', $product); $item->setCategories($categories); } }
/** * Declare order item instance * * @param Mage_Sales_Model_Order_Item $item * @return Mage_Sales_Model_Order_Shipment_Item */ public function setOrderItem(Mage_Sales_Model_Order_Item $item) { $this->_orderItem = $item; $this->setOrderItemId($item->getId()); return $this; }
/** * Decides if we need to create dummy shipment item or not * for eaxample we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used * @param Mage_Sales_Model_Order_Item $item * @param array $qtys * @return bool */ protected function _needToAddDummyForShipment($item, $qtys) { if ($item->getHasChildren()) { foreach ($item->getChildrenItems() as $child) { if ($child->getIsVirtual()) { continue; } if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) { return true; } } if ($item->isShipSeparately()) { return true; } return false; } else { if ($item->getParentItem()) { if ($item->getIsVirtual()) { return false; } if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) { return true; } return false; } } }
/** * Retrieve * * @param Mage_Sales_Model_Order_Item $item * @return unknown */ public function itemToQuoteItem(Mage_Sales_Model_Order_Item $item) { $quoteItem = Mage::getModel('sales/quote_item')->setStoreId($item->getOrder()->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setParentProductId($item->getParentProductId()); Mage::helper('core')->copyFieldset('sales_convert_order_item', 'to_quote_item', $item, $quoteItem); return $quoteItem; }
public function addItem(Mage_Sales_Model_Order_Item $item) { $item->setOrder($this); if (!$item->getId()) { $this->getItemsCollection()->addItem($item); } return $this; }
/** * Initialize creation data from existing order Item * * @param Mage_Sales_Model_Order_Item $orderItem * @param int $qty * @return Mage_Sales_Model_Quote_Item | string */ public function initFromOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = null) { if (!$orderItem->getId()) { return $this; } $product = Mage::getModel('catalog/product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId()); if ($product->getId()) { $product->setSkipCheckRequiredOption(true); $buyRequest = $orderItem->getBuyRequest(); if (is_numeric($qty)) { $buyRequest->setQty($qty); } $item = $this->getQuote()->addProduct($product, $buyRequest); if (is_string($item)) { return $item; } if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) { $item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions)))); } Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item)); return $item; } return $this; }
/** * Retrieve * * @param Mage_Sales_Model_Order_Item $item * @return unknown */ public function itemToQuoteItem(Mage_Sales_Model_Order_Item $item) { $quoteItem = AO::getModel('sales/quote_item')->setStoreId($item->getOrder()->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setParentProductId($item->getParentProductId()); AO::helper('core')->copyFieldset('sales_convert_order_item', 'to_quote_item', $item, $quoteItem); // ->setSku($item->getSku()) // ->setName($item->getName()) // ->setDescription($item->getDescription()) // ->setWeight($item->getWeight()) // ->setCustomPrice($item->getPrice()) // ->setDiscountPercent($item->getDiscountPercent()) // ->setDiscountAmount($item->getDiscountAmount()) // ->setTaxPercent($item->getTaxPercent()) // ->setTaxAmount($item->getTaxAmount()) // ->setRowWeight($item->getRowWeight()) // ->setRowTotal($item->getRowTotal()) // ->setAppliedRuleIds($item->getAppliedRuleIds()) // // ->setBaseDiscountAmount($item->getBaseDiscountAmount()) // ->setBaseTaxAmount($item->getBaseTaxAmount()) // ->setBaseRowTotal($item->getBaseRowTotal()) // ; return $quoteItem; }
/** * Retrieve order item statuses array * * @return array */ public static function getStatuses() { if (is_null(self::$_statuses)) { self::$_statuses = array(self::STATUS_PENDING => Mage::helper('sales')->__('Ordered'), self::STATUS_SHIPPED => Mage::helper('sales')->__('Shipped'), self::STATUS_INVOICED => Mage::helper('sales')->__('Invoiced'), self::STATUS_BACKORDERED => Mage::helper('sales')->__('Backordered'), self::STATUS_RETURNED => Mage::helper('sales')->__('Returned'), self::STATUS_REFUNDED => Mage::helper('sales')->__('Refunded'), self::STATUS_CANCELED => Mage::helper('sales')->__('Canceled'), self::STATUS_PARTIAL => Mage::helper('sales')->__('Partial'), self::STATUS_MIXED => Mage::helper('sales')->__('Mixed')); } return self::$_statuses; }
/** * Add item quantities to the XML * * @param Mage_Core_Block_Template $renderer Product renderer * @param Mage_XmlConnect_Model_Simplexml_Element $quantityXml * @param Mage_Sales_Model_Order_Item $item * @return null */ public function addQuantityToXml(Mage_Core_Block_Template $renderer, Mage_XmlConnect_Model_Simplexml_Element $quantityXml, Mage_Sales_Model_Order_Item $item) { $qty = 1 * $item->getQtyOrdered(); if ($qty > 0) { $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Ordered'))); } $qty = 1 * $item->getQtyShipped(); if ($qty > 0) { $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Shipped'))); } $qty = 1 * $item->getQtyCanceled(); if ($qty > 0) { $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Canceled'))); } $qty = 1 * $item->getQtyRefunded(); if ($qty > 0) { $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Refunded'))); } }
/** * Decides if we need to create dummy shipment item or not * for eaxample we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used * @param Mage_Sales_Model_Order_Item $item * @param array $qtys * @return bool */ protected function _needToAddDummy($item, $qtys) { if ($item->getHasChildren()) { foreach ($item->getChildrenItems() as $child) { if ($child->getIsVirtual()) { continue; } if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0 || !isset($qtys[$child->getId()]) && $child->getQtyToShip()) { return true; } } return false; } else { if ($item->getParentItem()) { if ($item->getIsVirtual()) { return false; } if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0 || !isset($qtys[$item->getParentItem()->getId()]) && $item->getParentItem()->getQtyToShip()) { return true; } return false; } } }