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


PHP Item::removeErrorInfosByParams方法代碼示例

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


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

示例1: testRemoveErrorInfosByParamsAllErrorsRemoved

 public function testRemoveErrorInfosByParamsAllErrorsRemoved()
 {
     $message = "message";
     $message2 = "message2";
     $this->errorInfos->expects($this->at(0))->method('addItem')->with(null, null, $message);
     $this->errorInfos->expects($this->at(1))->method('addItem')->with(null, null, $message2);
     $this->assertEquals($this->model, $this->model->addErrorInfo(null, null, $message));
     $this->assertEquals($this->model, $this->model->addErrorInfo(null, null, $message2));
     $this->assertEquals($message . "\n" . $message2, $this->model->getMessage());
     $params = [];
     $removedItems = [['message' => $message], ['message' => $message2]];
     $this->errorInfos->expects($this->once())->method('removeItemsByParams')->with($params)->will($this->returnValue($removedItems));
     $this->errorInfos->expects($this->once())->method('getItems')->will($this->returnValue([]));
     $this->assertEquals($this->model, $this->model->removeErrorInfosByParams($params));
     $this->assertFalse($this->model->getHasError());
     $this->assertEquals('', $this->model->getMessage());
 }
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例2: _removeErrorsFromQuoteAndItem

 /**
  * Removes error statuses from quote and item, set by this observer
  *
  * @param \Magento\Quote\Model\Quote\Item $item
  * @param int $code
  * @return void
  */
 protected function _removeErrorsFromQuoteAndItem($item, $code)
 {
     if ($item->getHasError()) {
         $params = ['origin' => 'cataloginventory', 'code' => $code];
         $item->removeErrorInfosByParams($params);
     }
     $quote = $item->getQuote();
     $quoteItems = $quote->getItemsCollection();
     $canRemoveErrorFromQuote = true;
     foreach ($quoteItems as $quoteItem) {
         if ($quoteItem->getItemId() == $item->getItemId()) {
             continue;
         }
         $errorInfos = $quoteItem->getErrorInfos();
         foreach ($errorInfos as $errorInfo) {
             if ($errorInfo['code'] == $code) {
                 $canRemoveErrorFromQuote = false;
                 break;
             }
         }
         if (!$canRemoveErrorFromQuote) {
             break;
         }
     }
     if ($quote->getHasError() && $canRemoveErrorFromQuote) {
         $params = ['origin' => 'cataloginventory', 'code' => $code];
         $quote->removeErrorInfosByParams(null, $params);
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:36,代碼來源:QuantityValidator.php


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