コード例 #1
0
 /**
  * When handling the after set qty event,
  * quote item quantities should be checked by checking
  * quote inventory via the quantity service model.
  */
 public function testHandleAfterSetItemQty()
 {
     $quoteItem = Mage::getModel('sales/quote_item');
     $this->_event->setItem($quoteItem);
     // Side-effect test: just need to make sure quote inventory
     // is checked via the quantity service model.
     $this->_quantityService->expects($this->once())->method('checkQuoteItemInventory')->with($this->identicalTo($quoteItem))->will($this->returnSelf());
     $this->_inventoryObserver->handleAfterSetItemQty($this->_eventObserver);
 }
コード例 #2
0
 /**
  * When handling the before collect totals event,
  * quote item quantities should be checked by checking
  * quote inventory via the quantity service model.
  */
 public function testHandleBeforeCollectTotals()
 {
     $quote = Mage::getModel('sales/quote');
     $this->_event->setQuote($quote);
     // Side-effect test: just need to make sure quote inventory
     // is checked via the quantity service model.
     $this->_quantityService->expects($this->once())->method('checkQuoteInventory')->with($this->identicalTo($quote))->will($this->returnSelf());
     $this->_inventoryObserver->handleBeforeCollectTotals($this->_eventObserver);
 }
コード例 #3
0
 /**
  * Before collecting item totals, check that all items
  * in the quote are available to be fulfilled.
  *
  * @param Varien_Event_Observer
  * @return self
  */
 public function handleBeforeCollectTotals(Varien_Event_Observer $observer)
 {
     try {
         $quote = $observer->getEvent()->getQuote();
         $this->quantityService->checkQuoteInventory($quote);
     } catch (EbayEnterprise_Inventory_Exception_Quantity_Collector_Exception $e) {
         $this->logger->warning($e->getMessage(), $this->logContext->getMetaData(__CLASS__, [], $e));
     }
     return $this;
 }
コード例 #4
0
 /**
  * Handle admin out of stock Exception thrown from ROM Inventory Service.
  *
  * @param  EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception
  * @param  Mage_Sales_Model_Quote
  * @return self
  */
 protected function handleAdminOrderException(EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception $e, Mage_Sales_Model_Quote $quote)
 {
     $this->getAdminQuoteSession()->addError($e->getMessage());
     foreach ($quote->getAllVisibleItems() as $quoteItem) {
         if (!$this->quantityService->isItemAvailable($quoteItem)) {
             $quote->deleteItem($quoteItem);
         }
     }
     return $this;
 }
コード例 #5
0
 /**
  * Return false if we have an item that's not backorderable or not out of stock
  * otherwise return true that all items are backorderable and out of stock.
  *
  * @param  Mage_Sales_Model_Quote
  * @return bool
  */
 protected function isAllItemBackorderableAndOutOfStock(Mage_Sales_Model_Quote $quote)
 {
     /** @var Mage_Sales_Model_Quote_Item[] $items */
     $items = $quote->getAllVisibleItems();
     foreach ($items as $item) {
         if ($this->quantityService->canSendInventoryAllocation($item)) {
             return false;
         }
     }
     return true;
 }
コード例 #6
0
 /**
  * Determine if an item is possible to send inventory detail request.
  *
  * @param  Mage_Sales_Model_Quote_Item_Abstract
  * @return bool
  */
 protected function isItemAllowInventoryDetail(Mage_Sales_Model_Quote_Item_Abstract $item)
 {
     if ($item->getHasChildren()) {
         foreach ($item->getChildren() as $childItem) {
             if ($this->quantityService->canSendInventoryDetail($childItem)) {
                 return true;
             }
         }
         return false;
     }
     return $this->quantityService->canSendInventoryDetail($item);
 }