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


PHP Mage_Sales_Model_Order::getItemsCollection方法代码示例

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


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

示例1: _shipOrder

 protected function _shipOrder(Mage_Sales_Model_Order $order)
 {
     $itemQty = $order->getItemsCollection()->count();
     $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
     $shipment = new Mage_Sales_Model_Order_Shipment_Api();
     $shipmentId = $shipment->create($order->getIncrementId());
 }
开发者ID:Farik2605,项目名称:tobi,代码行数:7,代码来源:Observer.php

示例2: _resuscitateCartItems

 /**
  * Re-añade los productos comprados a carrito nuevamente
  *
  * @param Mage_Sales_Model_Order $order
  * @return $this
  */
 protected function _resuscitateCartItems(Mage_Sales_Model_Order $order, Mage_Core_Controller_Front_Action $action = null)
 {
     foreach ($order->getItemsCollection() as $orderItem) {
         try {
             $this->getCart()->addOrderItem($orderItem);
         } catch (Mage_Core_Exception $e) {
             /** @var Mage_Checkout_Model_Session $session */
             $session = Mage::getSingleton('checkout/session');
             if ($session->getUseNotice(true)) {
                 $session->addNotice($e->getMessage());
             } else {
                 $session->addError($e->getMessage());
             }
             if ($action) {
                 $action->setRedirectWithCookieCheck('checkout/cart');
             }
         } catch (Exception $e) {
             /** @var Mage_Checkout_Model_Session $session */
             $session = Mage::getSingleton('checkout/session');
             $session->addNotice($e->getMessage());
             $session->addException($e, Mage::helper('checkout')->__('Cannot add the item to shopping cart.'));
             if ($action) {
                 $action->setRedirectWithCookieCheck('checkout/cart');
             }
         }
     }
     $this->getCart()->save();
     return $this;
 }
开发者ID:aplazame,项目名称:magento,代码行数:35,代码来源:Cart.php

示例3: _resuscitateCartItems

 /**
  * Re-añade los productos comprados a carrito nuevamente
  *
  * @param Mage_Sales_Model_Order $order
  * @return $this
  */
 protected function _resuscitateCartItems(Mage_Sales_Model_Order $order)
 {
     foreach ($order->getItemsCollection() as $orderItem) {
         $this->getCart()->addOrderItem($orderItem);
     }
     $this->getCart()->save();
     return $this;
 }
开发者ID:jgermade,项目名称:magento,代码行数:14,代码来源:Cart.php

示例4: getNetWeight

 public function getNetWeight(Mage_Sales_Model_Order $order)
 {
     $netWeight = 0;
     foreach ($order->getItemsCollection() as $item) {
         $productNetWeight = $item->getProduct()->getData($this->getNetWeightAttributeCode());
         $netWeight += $productNetWeight * $item->getQtyOrdered();
     }
     return $netWeight;
 }
开发者ID:xiaoguizhidao,项目名称:magento-weight-in-order-grid,代码行数:9,代码来源:Data.php

示例5: getTotalQtyItemsOrdered

/**
 * Returns the total quantity of ordered items of the given order.
 *
 * @param Mage_Sales_Model_Order $order The order to return info from
 * @return int The total quantity of ordered items
 */
function getTotalQtyItemsOrdered($order)
{
    $qty = 0;
    $orderedItems = $order->getItemsCollection();
    foreach ($orderedItems as $item) {
        if (!$item->isDummy()) {
            $qty += (int) $item->getQtyOrdered();
        }
    }
    return $qty;
}
开发者ID:Itipart,项目名称:Synchro,代码行数:17,代码来源:Abstract.php

示例6: _refundLineItems

 /**
  * @return array quantity of each item to be returned
  */
 protected function _refundLineItems()
 {
     $data = [];
     $qtys = $this->_clearReturnQtys();
     if ($this->_payload->isReturn()) {
         $items = $this->_order->getItemsCollection();
         foreach ($this->_payload->getOrderItems() as $orderItem) {
             $qtys = $this->_appendToQtyArray($orderItem, $items, $qtys);
         }
     }
     $data['qtys'] = $qtys;
     return $data;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:16,代码来源:Creditissued.php

示例7: 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]);
 }
开发者ID:WinstonN,项目名称:magento-retail-order-management,代码行数:25,代码来源:CreateTest.php

示例8: _getOrderItemQtys

 protected function _getOrderItemQtys(SimpleXMLElement $xmlItems, Mage_Sales_Model_Order $order)
 {
     $shipAll = !count((array) $xmlItems);
     /* @var $items Mage_Sales_Model_Mysql4_Order_Item_Collection */
     $items = $order->getItemsCollection();
     $qtys = array();
     $childs = array();
     /* @var $item Mage_Sales_Model_Order_Item */
     foreach ($items as $item) {
         /* collect all items qtys if shipall flag is true */
         if ($shipAll) {
             if ($item->getParentItemId()) {
                 $qtys[$item->getParentItemId()] = $item->getQtyOrdered();
             } else {
                 $qtys[$item->getId()] = $item->getQtyOrdered();
             }
             continue;
         }
         // search for item by SKU
         @(list($xmlItem) = $xmlItems->xpath(sprintf('//Item/SKU[text()="%s"]/..', addslashes($item->getSku()))));
         if ($xmlItem) {
             // store quantity by order item ID, not by SKU
             $qtys[$item->getId()] = (double) $xmlItem->Quantity;
         }
     }
     //Add child products into the shipments
     $intImportChildProducts = Mage::getStoreConfig('auctaneapi/general/import_child_products');
     if ($intImportChildProducts == 2) {
         $orderItems = $order->getAllItems();
         foreach ($orderItems as $objItem) {
             if ($objItem->getParentItemId()) {
                 //set parent item if not set
                 if (!$objItem->getParentItem()) {
                     $objItem->setParentItem(Mage::getModel('sales/order_item')->load($objItem->getParentItemId()));
                 }
                 if ($objItem->getParentItem()) {
                     //check for the bundle product type
                     if ($objItem->getParentItem()->getProductType() === 'bundle') {
                         $qtys[$objItem->getItemId()] = $qtys[$objItem->getParentItemId()];
                     }
                 }
             }
         }
     }
     return $qtys;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:46,代码来源:Shipnotify.php

示例9: refillCart

 /**
  * refill cart
  * 
  * @param Mage_Sales_Model_Order $order 
  *
  * @return void
  */
 public function refillCart($order)
 {
     // add items
     $cart = Mage::getSingleton('checkout/cart');
     foreach ($order->getItemsCollection() as $item) {
         try {
             $cart->addOrderItem($item);
         } catch (Exception $e) {
             Mage::log($e->getMessage());
         }
     }
     $cart->save();
     // add coupon code
     $coupon = $order->getCouponCode();
     $session = Mage::getSingleton('checkout/session');
     if (false == is_null($coupon)) {
         $session->getQuote()->setCouponCode($coupon)->save();
     }
 }
开发者ID:nomade-it,项目名称:MagentoPostFinance,代码行数:26,代码来源:Payment.php

示例10: _setShipGroups

 /**
  * Add ship groups to the request. For each address in the order, dispatch
  * an event for handling ship group destinations. For each ship group
  * destination added, trigger additional events for each item in the ship
  * group.
  *
  * @param Mage_Sales_Model_Order
  * @param IOrderCreateRequest
  * @return self
  */
 protected function _setShipGroups(Mage_Sales_Model_Order $order, IOrderCreateRequest $request)
 {
     $shipGroups = $request->getShipGroups();
     $orderItems = $request->getOrderItems();
     $destinations = $request->getDestinations();
     $itemCollection = $order->getItemsCollection();
     foreach ($order->getAddressesCollection() as $address) {
         $items = $this->_getItemsForAddress($address, $itemCollection);
         if ($items) {
             $shipGroups->offsetSet($this->_buildShipGroupForAddress($address, $items, $order, $shipGroups, $destinations, $orderItems));
         }
     }
     return $this;
 }
开发者ID:adderall,项目名称:magento-retail-order-management,代码行数:24,代码来源:Create.php

示例11: buildPlanItemsForSubscription

 /**
  * @param Mage_Sales_Model_Order $order
  *
  * @return array
  */
 public function buildPlanItemsForSubscription($order)
 {
     $list = [];
     $orderItems = $order->getItemsCollection();
     $orderSubtotal = $order->getQuote()->getSubtotal();
     $orderDiscount = $order->getDiscountAmount() * -1;
     $discount = null;
     if (!empty($orderDiscount)) {
         $discountPercentage = $orderDiscount * 100 / $orderSubtotal;
         $discountPercentage = number_format(floor($discountPercentage * 100) / 100, 2);
         $discount = [['discount_type' => 'percentage', 'percentage' => $discountPercentage]];
     }
     foreach ($orderItems as $item) {
         $product = Mage::getModel('catalog/product')->load($item->getProductId());
         if ($product->getTypeID() !== 'subscription') {
             Mage::throwException("O produto {$item->getName()} não é uma assinatura.");
             return false;
         }
         $productVindiId = $this->findOrCreateProduct(array('sku' => $item->getSku(), 'name' => $item->getName()));
         for ($i = 1; $i <= $item->getQtyOrdered(); $i++) {
             $list[] = ['product_id' => $productVindiId, 'pricing_schema' => ['price' => $item->getPrice()], 'discounts' => $discount];
         }
     }
     // Create product for shipping
     $productVindiId = $this->findOrCreateProduct(array('sku' => 'frete', 'name' => 'Frete'));
     $list[] = ['product_id' => $productVindiId, 'pricing_schema' => ['price' => $order->getShippingAmount()]];
     return $list;
 }
开发者ID:edvanmacedo,项目名称:vindi-magento,代码行数:33,代码来源:Api.php

示例12: initFromOrder

 /**
  * Initialize creation data from existing order
  *
  * @param Mage_Sales_Model_Order $order
  * @return unknown
  */
 public function initFromOrder(Mage_Sales_Model_Order $order)
 {
     if (!$order->getReordered()) {
         $this->getSession()->setOrderId($order->getId());
     } else {
         $this->getSession()->setReordered($order->getId());
     }
     /**
      * Check if we edit quest order
      */
     $this->getSession()->setCurrencyId($order->getOrderCurrencyCode());
     if ($order->getCustomerId()) {
         $this->getSession()->setCustomerId($order->getCustomerId());
     } else {
         $this->getSession()->setCustomerId(false);
     }
     $this->getSession()->setStoreId($order->getStoreId());
     $this->getSession()->getStore();
     //need for initializing store
     foreach ($order->getItemsCollection(Mage::helper('sarp')->getAllSubscriptionTypes(), true) as $orderItem) {
         /* @var $orderItem Mage_Sales_Model_Order_Item */
         if (!$this->hasSubscriptionOptions($orderItem)) {
             continue;
         }
         if (is_array($this->getItemIdFilter()) && sizeof($this->getItemIdFilter())) {
             // If itemId filter is set - ignore not matching entries
             if (array_search($orderItem->getId(), $this->getItemIdFilter()) === false) {
                 continue;
             }
         }
         if (!$orderItem->getParentItem()) {
             if ($order->getReordered()) {
                 $qty = $orderItem->getQtyOrdered();
             } else {
                 $qty = $orderItem->getQtyOrdered() - $orderItem->getQtyShipped() - $orderItem->getQtyInvoiced();
             }
             if ($qty > 0) {
                 $item = $this->initFromOrderItem($orderItem, $qty);
                 if (is_string($item)) {
                     Mage::throwException($item);
                 }
             }
         }
     }
     $this->_initBillingAddressFromOrder($order);
     $this->_initShippingAddressFromOrder($order);
     $this->setShippingMethod($order->getShippingMethod());
     $this->getQuote()->getShippingAddress()->setShippingDescription($order->getShippingDescription());
     $this->getQuote()->getBillingAddress()->setShippingDescription($order->getShippingDescription());
     $this->getQuote()->getPayment()->addData($order->getPayment()->getData());
     if ($order->getPayment()->getData('method') == 'ccsave') {
         $this->getQuote()->getPayment()->setAdditionalInformation('useccv', false);
     }
     $orderCouponCode = $order->getCouponCode();
     if ($orderCouponCode) {
         $this->getQuote()->setCouponCode($orderCouponCode);
     }
     if ($this->getQuote()->getCouponCode()) {
         //$this->getQuote()->collectTotals();
     }
     Mage::helper('core')->copyFieldset('sales_copy_order', 'to_edit', $order, $this->getQuote());
     Mage::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $this->getQuote()));
     if (!$order->getCustomerId()) {
         $this->getQuote()->setCustomerIsGuest(true);
     }
     if ($this->getSession()->getUseOldShippingMethod(true)) {
         /*
          * if we are making reorder or editing old order
          * we need to show old shipping as preselected
          * so for this we need to collect shipping rates
          */
         $this->collectShippingRates();
     } else {
         /*
          * if we are creating new order then we don't need to collect
          * shipping rates before customer hit appropriate button
          */
         $this->collectRates();
     }
     $this->saveQuote();
     // Make collect rates when user click "Get shipping methods and rates" in order creating
     // $this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
     // $this->getQuote()->getShippingAddress()->collectShippingRates();
     /** Check stock */
     foreach ($this->getQuote()->getItemsCollection() as $item) {
         $this->checkQuoteItemQty($item);
         if ($item->getProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
             $item->setMessage(Mage::helper('adminhtml')->__('This product is currently disabled'));
             $item->setHasError(true);
         }
         if ($item->getHasError()) {
             throw new AW_Sarp_Exception($item->getMessage());
         }
     }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:101,代码来源:Create.php

示例13: _cleanupFailedOrder

 /**
  * Remove ids and foreign keys between order objects that failed to be
  * saved.
  *
  * @param Mage_Sales_Model_Order
  * @return self
  */
 protected function _cleanupFailedOrder(Mage_Sales_Model_Order $order)
 {
     if (!$this->getCustomerSession()->isLoggedIn()) {
         // reset customer ID's on exception, because customer not saved
         $this->_quote->getCustomer()->setId(null);
     }
     //reset order id's on exception, because order not saved
     $order->setId(null);
     /** @var $item Mage_Sales_Model_Order_Item */
     foreach ($order->getItemsCollection() as $item) {
         $item->setOrderId(null)->setItemId(null)->setOrderAddressId(null);
     }
     return $this;
 }
开发者ID:WinstonN,项目名称:magento-retail-order-management,代码行数:21,代码来源:Quote.php

示例14: getOrderedVirtualGiftCards

 /**
  * Get all virtual gift card items from the collection of items in the
  * Magento order.
  *
  * @param Mage_Sales_Model_Order
  * @return Mage_Sales_Model_Order_Item[]
  */
 protected function getOrderedVirtualGiftCards(Mage_Sales_Model_Order $order)
 {
     $virtualGiftCards = [];
     foreach ($order->getItemsCollection() as $item) {
         if ($item->getProductType() === 'giftcard' && $item->getIsVirtual()) {
             $virtualGiftCards[] = $item;
         }
     }
     return $virtualGiftCards;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:17,代码来源:Giftcard.php

示例15: refillCart

 /**
  * refill cart
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return void
  */
 public function refillCart($order)
 {
     // add items
     $cart = Mage::getSingleton('checkout/cart');
     if (0 < $cart->getQuote()->getItemsCollection()->count()) {
         //cart is not empty, so refilling it is not required
         return;
     }
     foreach ($order->getItemsCollection() as $item) {
         try {
             $cart->addOrderItem($item);
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $cart->save();
     // add coupon code
     $coupon = $order->getCouponCode();
     $session = Mage::getSingleton('checkout/session');
     if (false == is_null($coupon)) {
         $session->getQuote()->setCouponCode($coupon)->save();
     }
 }
开发者ID:roshu1980,项目名称:add-computers,代码行数:30,代码来源:Payment.php


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