當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Observer::refundOrderInventory方法代碼示例

本文整理匯總了PHP中Observer::refundOrderInventory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Observer::refundOrderInventory方法的具體用法?PHP Observer::refundOrderInventory怎麽用?PHP Observer::refundOrderInventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Observer的用法示例。


在下文中一共展示了Observer::refundOrderInventory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRefundOrderInventory

 public function testRefundOrderInventory()
 {
     $websiteId = 0;
     $ids = ['1', '14'];
     $items = [];
     $isAutoReturnEnabled = true;
     $itemsToUpdate = [];
     foreach ($ids as $id) {
         $item = $this->getCreditMemoItem($id);
         $items[] = $item;
         $itemsToUpdate[$item->getProductId()] = $item->getQty();
     }
     $creditMemo = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', [], [], '', false);
     $creditMemo->expects($this->once())->method('getAllItems')->will($this->returnValue($items));
     $store = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId', '__wakeup'], [], '', false);
     $store->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $creditMemo->expects($this->once())->method('getStore')->will($this->returnValue($store));
     $this->stockConfiguration->expects($this->any())->method('isAutoReturnEnabled')->will($this->returnValue($isAutoReturnEnabled));
     $this->stockManagement->expects($this->once())->method('revertProductsSale')->with($itemsToUpdate, $websiteId);
     $this->stockIndexerProcessor->expects($this->once())->method('reindexList')->with($ids);
     $this->priceIndexer->expects($this->once())->method('reindexList')->with($ids);
     $this->event->expects($this->once())->method('getCreditmemo')->will($this->returnValue($creditMemo));
     $this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
     $this->observer->refundOrderInventory($this->eventObserver);
 }
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例2: refundOrderInventory

 public function refundOrderInventory()
 {
     $ids = ['1', '14'];
     $items = [];
     foreach ($ids as $id) {
         $items[] = $this->getCreditMemoItem($id);
     }
     $creditMemo = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', [], [], '', false);
     $creditMemo->expects($this->once())->method('getAllItems')->will($this->returnValue($items));
     $this->event->expects($this->once())->method('getCreditmemo')->will($this->returnValue($creditMemo));
     $this->catalogInventoryData->expects($this->once())->method('isAutoReturnEnabled')->will($this->returnValue(true));
     $this->stock->expects($this->once())->method('revertProductsSale')->with($items);
     $this->stockIndexProcessor->expects($this->once())->method('reidexList')->with($ids);
     $this->model->refundOrderInventory($this->eventObserver);
 }
開發者ID:,項目名稱:,代碼行數:15,代碼來源:


注:本文中的Observer::refundOrderInventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。