我正在尝试更新magento2中的报价项目。但是每次我保存项目时,都会使用相同的引用ID而不是更新它来创建一个新项目。这是我的代码
    public function __construct(
            \Magento\Quote\Model\QuoteRepository $quoteRepo
        ){
            $this->_quoteRepo = $quoteRepo;
        }
public function updateItem(){
    $quote = $this->_quoteRepo->get('id here');
    foreach($quote->getAllVisibleItems() as $itemq){
    $itemq->setQty(5);
    $itemq->setPrice(20);
    $itemq->save();
    }
 }
但是,每次它保存一个项目时,都会生成一个新项目。不知道为什么。也I couldn't find any class which explicitly load qoute item in magento2。帮助将不胜感激。
在这个问题上,/magento/139298/how-to-save-quote-items-in-magento-2他们正在设置整个产品...而不是尝试对其进行更新。设置产品时,肯定会生成新的报价项目。但是为什么在更新的情况下也这样做。
                
                2
              
                  如何在magento 2中保存报价项目的
                
                
                  
                    —
                    Ankit Shah 
                    
                  
                
              
                  不一样。我已经编辑了我的问题。@AnkitShah,请检查。
                
                
                  
                    —
                    金舒克Deb 
                    
                  
                
              
                  对于Magento 2.2+,请参阅此-magento.stackexchange.com/a/182152/4492
                
                
                  
                    —
                    Rohan Patil,