/** * 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; }
/** * * @param Mage_Sales_Model_Order_Item $item */ public function addSalesOrderItemFilter(Mage_Sales_Model_Order_Item $item) { $this->getSelect()->join(array('stqt' => $this->getTable('adm_warehouse/sales_item_quote')), 'main_table.stock_id=stqt.stock_id AND main_table.product_id=stqt.product_id', array('quote_qty' => 'stqt.qty'))->where('quote_item_id=?', $item->getQuoteItemId()); return $this; }
/** * Get item details for the given order item. * returns null if the item was excluded from the request or if * there was an error in the sdk * * @param Mage_Sales_Model_Order_Item * @return EbayEnterprise_Inventory_Model_Details_Item|null */ public function getDetailsForOrderItem(Mage_Sales_Model_Order_Item $item) { try { $result = $this->factory->createDetailsModel()->fetch($item->getOrder()->getQuote()); return !is_null($result) ? $result->lookupDetailsByItemId($item->getQuoteItemId()) : $result; } catch (EbayEnterprise_Inventory_Exception_Details_Operation_Exception $e) { return null; } }
/** * 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; }
/** * @param Mage_Sales_Model_Order_Item $orderItem * @return array */ public function prepareOrderItemData($orderItem) { $data = array($this->getOpportunityKey() => $orderItem->getQuoteItemId(), self::IS_CLOSED => true, self::IS_WON => true, self::CLOSE_DATE => $this->_getDateTimeHelper()->getServerDate(), self::STAGE => $this->_getHelper()->getHardcodedOpportunityFields("purchase_stage"), self::PROBABILITY => $this->_getHelper()->getHardcodedOpportunityFields("purchase_probability")); $this->_addCommonData($data); Mage::dispatchEvent("opportunity_dynamic_before_update", array("opportunity_data" => &$data, "order_item" => $orderItem)); return $data; }