本文整理汇总了PHP中Mage_Sales_Model_Order::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::addItem方法的具体用法?PHP Mage_Sales_Model_Order::addItem怎么用?PHP Mage_Sales_Model_Order::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::addItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addItemsToOrder
/**
* Add items to a passed in order object.
* @param Mage_Sales_Model_Order $order
* @param array $itemData
* @param string $itemColumn
* @param string $itemDataKey
* @param string $itemIdKey
* @return self
*/
protected function _addItemsToOrder(Mage_Sales_Model_Order $order, array $itemData, $itemColumn, $itemDataKey, $itemIdKey)
{
foreach ($itemData as $data) {
// see Mage_Sales_Model_Order::addItem method
// when a sales/order_item::getId exists it won't add the item to
// the collection.
$item = Mage::getModel('sales/order_item', [$itemColumn => $data[$itemDataKey]]);
$order->addItem($item);
$item->setItemId($data[$itemIdKey]);
}
return $this;
}
示例2: testGetItemsForAddressFiltering
/**
* When getting items for an address, only items that should be included
* in the order create request should be returned.
*/
public function testGetItemsForAddressFiltering()
{
// Create an item that is exptected to be excluded from the OCR and
// an items that should be included.
$excludedItem = Mage::getModel('sales/order_item', ['order_address_id' => $this->_shipAddressId]);
$includedItem = Mage::getModel('sales/order_item', ['order_address_id' => $this->_shipAddressId]);
$this->_order->addItem($excludedItem)->addItem($includedItem);
// Stubs
$api = $this->_httpApi;
$config = $this->getModelMock('eb2ccore/config_registry');
$payload = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IOrderCreateRequest');
$constructorArgs = ['api' => $api, 'config' => $config, 'order' => $this->_order, 'payload' => $payload, 'item_selection' => $this->_itemSelection];
$create = Mage::getModel('ebayenterprise_order/create', $constructorArgs);
// Mock the item selection helper such that if given the array of items
// that belong to the address - excluded and included items - that only
// the items that should be included are returned.
$this->_itemSelection->expects($this->any())->method('selectFrom')->with($this->identicalTo([$excludedItem, $includedItem]))->will($this->returnValue([$includedItem]));
$itemsForAddress = EcomDev_Utils_Reflection::invokeRestrictedMethod($create, '_getItemsForAddress', [$this->_shipAddress, $this->_order->getItemsCollection()]);
$this->assertCount(1, $itemsForAddress);
$this->assertSame($includedItem, $itemsForAddress[0]);
}
示例3: saveNewOrderItems
/**
* Add new products to order
*
* @param Mage_Sales_Model_Quote $quote
* @param Mage_Sales_Model_Order $order
* @param $changes
* @return $this
*/
public function saveNewOrderItems(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order, $changes)
{
foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $order->getItemByQuoteItemId($quoteItem->getItemId());
if ($orderItem && $orderItem->getItemId()) {
continue;
}
$quoteItem->save();
$orderItem = $this->getConvertor()->itemToOrderItem($quoteItem, $orderItem);
$order->addItem($orderItem);
$orderItem->save();
/*** Add new items to log ***/
$changedItem = $quoteItem;
$itemChange = array('name' => $changedItem->getName(), 'qty_before' => 0, 'qty_after' => $changedItem->getQty());
$this->getLogModel()->addItemChange($changedItem->getId(), $itemChange);
$this->_savedOrderItems[] = $orderItem->getItemId();
}
foreach ($quote->getAllItems() as $childQuoteItem) {
$parentOrderItem = false;
$childOrderItem = $order->getItemByQuoteItemId($childQuoteItem->getItemId());
/*** Add items relations for configurable and bundle products ***/
if ($childQuoteItem->getParentItemId()) {
$parentOrderItem = $order->getItemByQuoteItemId($childQuoteItem->getParentItemId());
$childOrderItem->setParentItemId($parentOrderItem->getItemId());
$childOrderItem->save();
}
// /*** Add new items to log ***/
// $changedItem = $parentOrderItem ? $parentOrderItem : $childOrderItem;
// $itemChange = array(
// 'name' => $changedItem->getName(),
// 'qty_before' => 0,
// 'qty_after' => $changedItem->getQtyToRefund() + $changedItem->getQtyToCancel()
// );
// $this->getLogModel()->addItemChange($changedItem->getId(), $itemChange);
}
return $this;
}
示例4:
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Magento
* @package Mage_Downlodable
* @subpackage integration_tests
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
$billingAddress = new Mage_Sales_Model_Order_Address(array('firstname' => 'guest', 'lastname' => 'guest', 'email' => 'customer@example.com', 'street' => 'street', 'city' => 'Los Angeles', 'region' => 'CA', 'postcode' => '1', 'country_id' => 'US', 'telephone' => '1'));
$billingAddress->setAddressType('billing');
$payment = new Mage_Sales_Model_Order_Payment();
$payment->setMethod('checkmo');
$orderItem = new Mage_Sales_Model_Order_Item();
$orderItem->setProductId(1)->setProductType(Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE)->setBasePrice(100)->setQtyOrdered(1);
$order = new Mage_Sales_Model_Order();
$order->addItem($orderItem)->setIncrementId('100000001')->setCustomerIsGuest(true)->setStoreId(1)->setEmailSent(1)->setBillingAddress($billingAddress)->setPayment($payment);
$order->save();
示例5: _createOrderItems
/**
* Create order items for quote items belonging to an address.
*
* @param Mage_Sales_Model_Quote_Item_Abstract[]
* @param Mage_Sales_Model_Order_Address
* @param Mage_Sales_Model_Order
* @return self
*/
protected function _createOrderItems(array $quoteItems, Mage_Sales_Model_Order_Address $orderAddress, Mage_Sales_Model_Order $order)
{
foreach ($quoteItems as $quoteAddressItem) {
$orderItem = $this->_convertor->itemToOrderItem($quoteAddressItem)->setOrderAddress($orderAddress)->setProductType($this->_getItemProductType($quoteAddressItem));
$order->addItem($orderItem);
}
return $this;
}