Skip to main content
improved formatting.
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty)$quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_itemquote_item table

Below is my Function on that function i am able to create quote

public function save(\Magento\Quote\Api\Data\CartInterface $quote) {

public function save(\Magento\Quote\Api\Data\CartInterface $quote)
{
 
    
    if ($quote->getId()) {
    
       $currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
                
            
     foreach ($currentQuote->getData() as $key => $value) {
        
          if (!$quote->hasData($key)) {
                $quote->setData($key, $value);
            }
        }
    
   
    $quote->setItemscount(count($this->sku)); 
    $quote->setItemsqty($this->qty);
 
   
    }

  
    $this->getSaveHandler()->save($quote);

    $quoteItem = $this->quoteItemFactory->create();
    $quoteItem->setProduct($product);

    $quoteObj->addItem($quoteItem);
    $quoteObj->collectTotals()->save();


    $this->customlog->info($quoteItem->getData());

    unset($this->quotesById[$quote->getId()]);
    unset($this->quotesByCustomerId[$quote->getCustomerId()]);
}

How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table

Below is my Function on that function i am able to create quote

public function save(\Magento\Quote\Api\Data\CartInterface $quote) {

    if ($quote->getId()) {
    
       $currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
                
            
     foreach ($currentQuote->getData() as $key => $value) {
        
          if (!$quote->hasData($key)) {
                $quote->setData($key, $value);
            }
        }
    
   
    $quote->setItemscount(count($this->sku)); 
    $quote->setItemsqty($this->qty);
 
   
    }

  
    $this->getSaveHandler()->save($quote);

    $quoteItem = $this->quoteItemFactory->create();
    $quoteItem->setProduct($product);

    $quoteObj->addItem($quoteItem);
    $quoteObj->collectTotals()->save();


    $this->customlog->info($quoteItem->getData());

    unset($this->quotesById[$quote->getId()]);
    unset($this->quotesByCustomerId[$quote->getCustomerId()]);
}

How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table

Below is my Function on that function i am able to create quote

public function save(\Magento\Quote\Api\Data\CartInterface $quote)
{
 
    
    if ($quote->getId()) {
    
       $currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
                
            
     foreach ($currentQuote->getData() as $key => $value) {
        
          if (!$quote->hasData($key)) {
                $quote->setData($key, $value);
            }
        }
    
   
    $quote->setItemscount(count($this->sku)); 
    $quote->setItemsqty($this->qty);
 
   
    }

  
    $this->getSaveHandler()->save($quote);

    $quoteItem = $this->quoteItemFactory->create();
    $quoteItem->setProduct($product);

    $quoteObj->addItem($quoteItem);
    $quoteObj->collectTotals()->save();


    $this->customlog->info($quoteItem->getData());

    unset($this->quotesById[$quote->getId()]);
    unset($this->quotesByCustomerId[$quote->getCustomerId()]);
}

How to do it? Any idea?

added 1121 characters in body
Source Link
magento12345
  • 471
  • 1
  • 9
  • 20

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table

Below is my Function on that function i am able to create quote

public function save(\Magento\Quote\Api\Data\CartInterface $quote) How{

    if ($quote->getId()) {
    
       $currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
                
            
     foreach ($currentQuote->getData() as $key => $value) {
        
          if (!$quote->hasData($key)) {
                $quote->setData($key, $value);
            }
        }
    
   
    $quote->setItemscount(count($this->sku)); 
    $quote->setItemsqty($this->qty);
 
   
    }

  
    $this->getSaveHandler()->save($quote);

    $quoteItem = $this->quoteItemFactory->create();
    $quoteItem->setProduct($product);

    $quoteObj->addItem($quoteItem);
    $quoteObj->collectTotals()->save();


    $this->customlog->info($quoteItem->getData());

    unset($this->quotesById[$quote->getId()]);
    unset($this->quotesByCustomerId[$quote->getCustomerId()]);
}

How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table

Below is my Function on that function i am able to create quote

public function save(\Magento\Quote\Api\Data\CartInterface $quote) {

    if ($quote->getId()) {
    
       $currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
                
            
     foreach ($currentQuote->getData() as $key => $value) {
        
          if (!$quote->hasData($key)) {
                $quote->setData($key, $value);
            }
        }
    
   
    $quote->setItemscount(count($this->sku)); 
    $quote->setItemsqty($this->qty);
 
   
    }

  
    $this->getSaveHandler()->save($quote);

    $quoteItem = $this->quoteItemFactory->create();
    $quoteItem->setProduct($product);

    $quoteObj->addItem($quoteItem);
    $quoteObj->collectTotals()->save();


    $this->customlog->info($quoteItem->getData());

    unset($this->quotesById[$quote->getId()]);
    unset($this->quotesByCustomerId[$quote->getCustomerId()]);
}

How to do it? Any idea?

added 130 characters in body
Source Link
magento12345
  • 471
  • 1
  • 9
  • 20

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

HowI am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

How to do it? Any idea?

How to save quote items in Magento 2? I have quote id. I'm able to store quote table data but I want to store products name, sku which is going in quote_item table.

I am able to set Data in quote table . $quote->setItemsqty($this->qty);

But i want to set Sku ,Name etc on quote_item table How to do it? Any idea?

improved formatting.
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156
Loading
format the code
Source Link
Manashvi Birla
  • 8.9k
  • 9
  • 28
  • 53
Loading
Source Link
magento12345
  • 471
  • 1
  • 9
  • 20
Loading