本文整理汇总了PHP中Mage_Sales_Model_Order_Item::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Item::getId方法的具体用法?PHP Mage_Sales_Model_Order_Item::getId怎么用?PHP Mage_Sales_Model_Order_Item::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Item::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initFromOrderItem
/**
* 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;
}
示例2: setOrderItem
/**
* 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;
}
示例3: addItem
public function addItem(Mage_Sales_Model_Order_Item $item)
{
$item->setOrder($this);
if (!$item->getId()) {
$this->getItemsCollection()->addItem($item);
}
return $this;
}
示例4: itemToQuoteItem
/**
* 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;
}
示例5: initFromOrderItem
/**
* 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;
}
示例6: itemToQuoteItem
/**
* 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;
}
示例7: _calculateRefundedQty
/**
* Calculate refund qty
*
* @param Varien_Object $dataObject
* @param Mage_Sales_Model_Order_Item $orderItem
* @return array [not_ship, shipped, total, had_refunded]
*/
protected function _calculateRefundedQty($dataObject, $orderItem)
{
$creditMemo = $dataObject->getCreditmemoObject();
$order = $dataObject->getOrder();
$parentItemId = $orderItem->getParentItemId();
$refundItem = $creditMemo->getItemByOrderId($orderItem->getId());
$parentItem = $parentItemId ? $creditMemo->getItemByOrderId($parentItemId) : false;
if (is_bool($refundItem)) {
$refundQty = $parentItem ? $parentItem->getQty() : 0;
} else {
$refundQty = $parentItem ? $parentItem->getQty() * $refundItem->getQty() : $refundItem->getQty();
}
$oldCreditmemos = $order->getCreditmemosCollection();
/* total refuned qty before created this creditmemo */
$hadRefundedQty = 0;
if (count($oldCreditmemos)) {
foreach ($oldCreditmemos as $oldCreditmemo) {
if ($oldCreditmemo->getId() == $creditMemo->getId()) {
continue;
}
$item = $oldCreditmemo->getItemByOrderId($orderItem->getId());
if ($item) {
$parentItem = $orderItem->getParentItemId() ? $oldCreditmemo->getItemByOrderId($orderItem->getParentItemId()) : false;
$hadRefundedQty += $parentItem ? $parentItem->getQty() * $item->getQty() : $item->getQty();
}
}
}
/* calculate shipped qty */
$shippedQty = $orderItem->getQtyShipped();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$shippedQty = $parentOrderItem->getQtyShipped();
}
}
/* calculate canceled qty */
$canceledQty = $orderItem->getQtyCanceled();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$canceledQty = $parentOrderItem->getQtyCanceled();
}
}
/* total qty which we need to ship before created this credit memo */
$needToShipQty = $orderItem->getQtyOrdered() - $shippedQty - $hadRefundedQty - $canceledQty;
$needToShipQty = $needToShipQty >= 0 ? $needToShipQty : 0;
/* separate refund qty to qty of not_ship items & qty of shipped items */
$refundQtys = array('not_ship' => min($refundQty, $needToShipQty), 'shipped' => $refundQty - min($refundQty, $needToShipQty), 'total' => $refundQty, 'had_refunded' => $hadRefundedQty);
return $refundQtys;
}
示例8: _canRefundNoDummyItem
/**
* Check if no dummy order item can be refunded
*
* @param Mage_Sales_Model_Order_Item $item
* @param array $invoiceQtysRefundLimits
* @return bool
*/
protected function _canRefundNoDummyItem($item, $invoiceQtysRefundLimits = array())
{
if ($item->getQtyToRefund() < 0) {
return false;
}
if (isset($invoiceQtysRefundLimits[$item->getId()])) {
return $invoiceQtysRefundLimits[$item->getId()] > 0;
}
return true;
}
示例9: _getAndUpdatePaidInvoiceItems
/**
* Return the qty of newly paid invoice items for gift card.
* This method depends on giftcard_paid_invoice_items field in product options array.
* It also update the field with the newly paid invoice items
*
* @param Mage_Sales_Model_Order_Item $item giftcard order item
* @return int qty of newly paid invoice items
*/
protected function _getAndUpdatePaidInvoiceItems(Mage_Sales_Model_Order_Item $item)
{
$newlyPaidInvoiceItemQty = 0;
$options = $item->getProductOptions();
$paidInvoiceItems = isset($options['giftcard_paid_invoice_items']) ? $options['giftcard_paid_invoice_items'] : array();
// find invoice for this order item
$invoiceItemCollection = Mage::getResourceModel('sales/order_invoice_item_collection')->addFieldToFilter('order_item_id', $item->getId());
foreach ($invoiceItemCollection as $invoiceItem) {
$invoiceId = $invoiceItem->getParentId();
if (isset($this->_loadedInvoices[$invoiceId])) {
$invoice = $this->_loadedInvoices[$invoiceId];
} else {
$invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
$this->_loadedInvoices[$invoiceId] = $invoice;
}
// check, if this order item has been paid
if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID && !in_array($invoiceItem->getId(), $paidInvoiceItems)) {
$newlyPaidInvoiceItemQty += $invoiceItem->getQty();
$paidInvoiceItems[] = $invoiceItem->getId();
}
}
$options['giftcard_paid_invoice_items'] = $paidInvoiceItems;
$item->setProductOptions($options);
return $newlyPaidInvoiceItemQty;
}
示例10: reorderItem
/**
* Add new item to quote based on existing order Item
*
* @param Mage_Sales_Model_Order_Item $orderItem
* @return Mage_Sales_Model_Quote_Item
* @throws Mage_Core_Exception
*/
public function reorderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = 1)
{
if (!$orderItem->getId()) {
Mage::throwException(Mage::helper('enterprise_checkout')->__('Failed to reorder item'));
}
$product = Mage::getModel('catalog/product')->setStoreId($this->getStore()->getId())->load($orderItem->getProductId());
if ($product->getId()) {
$info = $orderItem->getProductOptionByCode('info_buyRequest');
$info = new Varien_Object($info);
$product->setSkipCheckRequiredOption(true);
$item = $this->createQuote()->addProduct($product, $info);
if (is_string($item)) {
Mage::throwException($item);
}
$item->setQty($qty);
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;
} else {
Mage::throwException(Mage::helper('enterprise_checkout')->__('Failed to add a product of order item'));
}
}
示例11: itemToQuoteItem
/**
* 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->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setSuperProductId($item->getSuperProductId())->setParentProductId($item->getParentProductId())->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;
}
示例12: refundOrderItem
/**
* Refund specific qty of order item
*
* @param Mage_Sales_Model_Order $order
* @param Mage_Sales_Model_Order_Item $orderItem
* @param $qtyToRefund
* @return $this
*/
public function refundOrderItem(Mage_Sales_Model_Order $order, Mage_Sales_Model_Order_Item $orderItem, $qtyToRefund)
{
$cmModel = Mage::getSingleton('mageworx_orderspro/edit_creditmemo');
$cmModel->addItemToRefund($orderItem->getId(), $qtyToRefund);
if ($orderItem->getProductType() == 'bundle') {
$orderItem->setQtyRefunded($qtyToRefund);
}
return $this;
}
示例13: _createSimpleOrderLineData
/**
* Returns SimpleOrderLineData record
*
* @param Mage_Sales_Model_Order_Item $item
* @return array
*/
protected function _createSimpleOrderLineData(Mage_Sales_Model_Order_Item $item)
{
/** @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->load($item->getProductId());
$data = array('orderLineId' => null, 'itemId' => (string) $item->getId(), 'orderNumber' => (string) $this->getOrderNumber(), 'quantity' => (double) $item->getQtyOrdered(), 'productSku' => (string) $item->getSku(), 'itemDescription' => (string) ($product->getShortDescription() ? $product->getShortDescription() : $product->getDescription()), 'unitPrice' => $this->_createOrderLinePrice($item, $item->getQtyOrdered()), 'totalTaxAmount' => $this->_createCurrencyAmount($item->getTaxAmount()), 'status' => $this->_createOrderItemStatus($item), 'price' => $this->_createCurrencyAmount($item->getBaseRowTotal()), 'allDiscounts' => null, 'dateCancelled' => null, 'dateDelivered' => null, 'dateShipped' => null, 'dateReturned' => null, 'dateInvoiced' => null, 'destination' => $this->_createShipTo($item->getOrder()->getShippingAddress()), 'shipmentId' => null, 'offerId' => null, 'offerUrl' => null);
return $data;
}
示例14: _refundItem
/**
* update quantity to refund
*
* @param Mage_Sales_Model_Order_Item $item
* @param array() $dataQty
* @param int $keepQty
* @return array() $dataQty
*/
private function _refundItem($item, $dataQty, $keepQty = 0)
{
$refundQty = $item->getQtyToRefund() - $keepQty;
if ($refundQty > 0) {
// set quantity to refund
$dataQty[$item->getId()] = $refundQty;
// search child to by refund as well
$childItems = $item->getChildrenItems();
foreach ($childItems as $child) {
$dataQty = $this->_refundItem($child, $dataQty, $keepQty);
}
}
return $dataQty;
}
示例15: getAssignedSerials
/**
* @param Mage_Sales_Model_Order_Item $orderItem
* @return array
*/
public function getAssignedSerials(Mage_Sales_Model_Order_Item $orderItem)
{
$gpSku = $this->getGpSkuFromProductId($orderItem->getProductId());
$select = $this->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('serial')->where('enabled = ?', true)->where('order_item_id = ?', $orderItem->getId())->where('gp_sku = ?', $gpSku);
$assignedSerials = array();
foreach ($this->getConnection()->fetchAll($select) as $serial) {
$assignedSerials[] = $serial['serial'];
}
return $assignedSerials;
}