Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller
iPad being using in wall mount battery swollen
Should I cover my bicycle overnight while bikepacking?
Do UK voters know if their MP will be the Speaker of the House?
Why can't we play rap on piano?
Plagiarism or not?
Why didn't Miles's spider sense work before?
How to tell a function to use the default argument values?
Short story with a alien planet, government officials must wear exploding medallions
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
What about the virus in 12 Monkeys?
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
Avoiding the "not like other girls" trope?
Apex Framework / library for consuming REST services
Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?
Method Does Not Exist error message
How to show a landlord what we have in savings?
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
How do I handle a potential work/personal life conflict as the manager of one of my friends?
How do I gain back my faith in my PhD degree?
Assassin's bullet with mercury
Can compressed videos be decoded back to their uncompresed original format?
ssTTsSTtRrriinInnnnNNNIiinngg
Why doesn't using multiple commands with a || or && conditional work?
What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"
Can not update quote_id field of “quote_item” table magento 2
Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller
I want to assign items added to cart by one customer to the other customer's cart.
For this I see two tables responsible for holding that data. One is table named "quote" and other is "Quote_item".The customer in which I want to transfer the cart item already has a quote created on quote table. so I thought changing the quote_id of that customer on quote_item
table would do the trick.
Let me explain by example:
Let us assume we have two customer with quote id 1 and 2.
Customer 1 added a product to the cart so on quote_item table the item will be saved with quote id 1. so if I could change the quote id of that item to 2 than that product will be assigned to customer 2.
I tried it by manually changing to the database and it worked. But When I tried to update that table programatically than it couldn't update the row. I think there is some kind of dependencies that I couldn't figure out.So I hope if someone could help me figure it out.
Below is the update code that I have written.
$_objectManager = MagentoFrameworkAppObjectManager::getInstance();
$quoteItemModel = $_objectManager->create('MagentoQuoteModelQuoteItem');
//filter the product with same quote id
$productCollection = $_objectManager->create('MagentoQuoteModelResourceModelQuoteItemCollection')->addFieldToFilter('quote_id',$quoteId);
if($products = $productCollection->getData()){
foreach ($products as $product)
$itemId = $product['item_id'];
$data = array();
//just putting a static value to check if the data gets updated
$data['quote_id']='2';
//updating the quote_item table
$quoteItemModel->load($itemId)->addData($data);
try
$quoteItemModel->setId($itemId)->save();
echo "Data updated successfully.";
catch (Exception $e)
echo $e->getMessage();
I know the code works perfectly with other custom tables.But in this case it is not updating the data.
Its gives below error:
Fatal error: Call to a member function getStoreId() on null in
E:xampphtdocs...vendormagentomodule-quoteModelQuoteItemAbstractItem.php
on line 144
When I checked that file. The function is:
public function getProduct()
{
$product = $this->_getData('product');
if ($product === null && $this->getProductId())
$product = clone $this->productRepository->getById(
$this->getProductId(),
false,
$this->getQuote()->getStoreId()
);
$this->setProduct($product);
I don't understand what it has to do with the update of table quote_item.I think there is some foreign key constraints or some dependency which is why it is not letting me update the quote_id of quote_item table.
Can some genius mind please help me out here or clearify what could have possibly gone wrong?
Actually I searched the whole internet and also posted question on stackoverflow about the migration of customer cart from one customer to another but still I haven't got a perfect working solution for it.
If someone could help me on this, it would be greatly appreciated.
Thanks.
magento2 magento-2.1
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I want to assign items added to cart by one customer to the other customer's cart.
For this I see two tables responsible for holding that data. One is table named "quote" and other is "Quote_item".The customer in which I want to transfer the cart item already has a quote created on quote table. so I thought changing the quote_id of that customer on quote_item
table would do the trick.
Let me explain by example:
Let us assume we have two customer with quote id 1 and 2.
Customer 1 added a product to the cart so on quote_item table the item will be saved with quote id 1. so if I could change the quote id of that item to 2 than that product will be assigned to customer 2.
I tried it by manually changing to the database and it worked. But When I tried to update that table programatically than it couldn't update the row. I think there is some kind of dependencies that I couldn't figure out.So I hope if someone could help me figure it out.
Below is the update code that I have written.
$_objectManager = MagentoFrameworkAppObjectManager::getInstance();
$quoteItemModel = $_objectManager->create('MagentoQuoteModelQuoteItem');
//filter the product with same quote id
$productCollection = $_objectManager->create('MagentoQuoteModelResourceModelQuoteItemCollection')->addFieldToFilter('quote_id',$quoteId);
if($products = $productCollection->getData()){
foreach ($products as $product)
$itemId = $product['item_id'];
$data = array();
//just putting a static value to check if the data gets updated
$data['quote_id']='2';
//updating the quote_item table
$quoteItemModel->load($itemId)->addData($data);
try
$quoteItemModel->setId($itemId)->save();
echo "Data updated successfully.";
catch (Exception $e)
echo $e->getMessage();
I know the code works perfectly with other custom tables.But in this case it is not updating the data.
Its gives below error:
Fatal error: Call to a member function getStoreId() on null in
E:xampphtdocs...vendormagentomodule-quoteModelQuoteItemAbstractItem.php
on line 144
When I checked that file. The function is:
public function getProduct()
{
$product = $this->_getData('product');
if ($product === null && $this->getProductId())
$product = clone $this->productRepository->getById(
$this->getProductId(),
false,
$this->getQuote()->getStoreId()
);
$this->setProduct($product);
I don't understand what it has to do with the update of table quote_item.I think there is some foreign key constraints or some dependency which is why it is not letting me update the quote_id of quote_item table.
Can some genius mind please help me out here or clearify what could have possibly gone wrong?
Actually I searched the whole internet and also posted question on stackoverflow about the migration of customer cart from one customer to another but still I haven't got a perfect working solution for it.
If someone could help me on this, it would be greatly appreciated.
Thanks.
magento2 magento-2.1
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02
add a comment |
I want to assign items added to cart by one customer to the other customer's cart.
For this I see two tables responsible for holding that data. One is table named "quote" and other is "Quote_item".The customer in which I want to transfer the cart item already has a quote created on quote table. so I thought changing the quote_id of that customer on quote_item
table would do the trick.
Let me explain by example:
Let us assume we have two customer with quote id 1 and 2.
Customer 1 added a product to the cart so on quote_item table the item will be saved with quote id 1. so if I could change the quote id of that item to 2 than that product will be assigned to customer 2.
I tried it by manually changing to the database and it worked. But When I tried to update that table programatically than it couldn't update the row. I think there is some kind of dependencies that I couldn't figure out.So I hope if someone could help me figure it out.
Below is the update code that I have written.
$_objectManager = MagentoFrameworkAppObjectManager::getInstance();
$quoteItemModel = $_objectManager->create('MagentoQuoteModelQuoteItem');
//filter the product with same quote id
$productCollection = $_objectManager->create('MagentoQuoteModelResourceModelQuoteItemCollection')->addFieldToFilter('quote_id',$quoteId);
if($products = $productCollection->getData()){
foreach ($products as $product)
$itemId = $product['item_id'];
$data = array();
//just putting a static value to check if the data gets updated
$data['quote_id']='2';
//updating the quote_item table
$quoteItemModel->load($itemId)->addData($data);
try
$quoteItemModel->setId($itemId)->save();
echo "Data updated successfully.";
catch (Exception $e)
echo $e->getMessage();
I know the code works perfectly with other custom tables.But in this case it is not updating the data.
Its gives below error:
Fatal error: Call to a member function getStoreId() on null in
E:xampphtdocs...vendormagentomodule-quoteModelQuoteItemAbstractItem.php
on line 144
When I checked that file. The function is:
public function getProduct()
{
$product = $this->_getData('product');
if ($product === null && $this->getProductId())
$product = clone $this->productRepository->getById(
$this->getProductId(),
false,
$this->getQuote()->getStoreId()
);
$this->setProduct($product);
I don't understand what it has to do with the update of table quote_item.I think there is some foreign key constraints or some dependency which is why it is not letting me update the quote_id of quote_item table.
Can some genius mind please help me out here or clearify what could have possibly gone wrong?
Actually I searched the whole internet and also posted question on stackoverflow about the migration of customer cart from one customer to another but still I haven't got a perfect working solution for it.
If someone could help me on this, it would be greatly appreciated.
Thanks.
magento2 magento-2.1
I want to assign items added to cart by one customer to the other customer's cart.
For this I see two tables responsible for holding that data. One is table named "quote" and other is "Quote_item".The customer in which I want to transfer the cart item already has a quote created on quote table. so I thought changing the quote_id of that customer on quote_item
table would do the trick.
Let me explain by example:
Let us assume we have two customer with quote id 1 and 2.
Customer 1 added a product to the cart so on quote_item table the item will be saved with quote id 1. so if I could change the quote id of that item to 2 than that product will be assigned to customer 2.
I tried it by manually changing to the database and it worked. But When I tried to update that table programatically than it couldn't update the row. I think there is some kind of dependencies that I couldn't figure out.So I hope if someone could help me figure it out.
Below is the update code that I have written.
$_objectManager = MagentoFrameworkAppObjectManager::getInstance();
$quoteItemModel = $_objectManager->create('MagentoQuoteModelQuoteItem');
//filter the product with same quote id
$productCollection = $_objectManager->create('MagentoQuoteModelResourceModelQuoteItemCollection')->addFieldToFilter('quote_id',$quoteId);
if($products = $productCollection->getData()){
foreach ($products as $product)
$itemId = $product['item_id'];
$data = array();
//just putting a static value to check if the data gets updated
$data['quote_id']='2';
//updating the quote_item table
$quoteItemModel->load($itemId)->addData($data);
try
$quoteItemModel->setId($itemId)->save();
echo "Data updated successfully.";
catch (Exception $e)
echo $e->getMessage();
I know the code works perfectly with other custom tables.But in this case it is not updating the data.
Its gives below error:
Fatal error: Call to a member function getStoreId() on null in
E:xampphtdocs...vendormagentomodule-quoteModelQuoteItemAbstractItem.php
on line 144
When I checked that file. The function is:
public function getProduct()
{
$product = $this->_getData('product');
if ($product === null && $this->getProductId())
$product = clone $this->productRepository->getById(
$this->getProductId(),
false,
$this->getQuote()->getStoreId()
);
$this->setProduct($product);
I don't understand what it has to do with the update of table quote_item.I think there is some foreign key constraints or some dependency which is why it is not letting me update the quote_id of quote_item table.
Can some genius mind please help me out here or clearify what could have possibly gone wrong?
Actually I searched the whole internet and also posted question on stackoverflow about the migration of customer cart from one customer to another but still I haven't got a perfect working solution for it.
If someone could help me on this, it would be greatly appreciated.
Thanks.
magento2 magento-2.1
magento2 magento-2.1
edited Dec 11 '16 at 15:11
Nitin Pawar
79911438
79911438
asked Dec 11 '16 at 14:59
aton1004aton1004
653823
653823
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02
add a comment |
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02
add a comment |
1 Answer
1
active
oldest
votes
could you explain more your task ? the customer 1 has to keep his quote and items ? and the customer 2 just have the same items than the customer 1 that's it?
In this case just use the addProduct
method which take 2 parameters ($product, $qty
).
Get the items from customer 1's quote. Loop on it, and add product to your customer 2's quote.
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f149798%2fcan-not-update-quote-id-field-of-quote-item-table-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
could you explain more your task ? the customer 1 has to keep his quote and items ? and the customer 2 just have the same items than the customer 1 that's it?
In this case just use the addProduct
method which take 2 parameters ($product, $qty
).
Get the items from customer 1's quote. Loop on it, and add product to your customer 2's quote.
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
add a comment |
could you explain more your task ? the customer 1 has to keep his quote and items ? and the customer 2 just have the same items than the customer 1 that's it?
In this case just use the addProduct
method which take 2 parameters ($product, $qty
).
Get the items from customer 1's quote. Loop on it, and add product to your customer 2's quote.
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
add a comment |
could you explain more your task ? the customer 1 has to keep his quote and items ? and the customer 2 just have the same items than the customer 1 that's it?
In this case just use the addProduct
method which take 2 parameters ($product, $qty
).
Get the items from customer 1's quote. Loop on it, and add product to your customer 2's quote.
could you explain more your task ? the customer 1 has to keep his quote and items ? and the customer 2 just have the same items than the customer 1 that's it?
In this case just use the addProduct
method which take 2 parameters ($product, $qty
).
Get the items from customer 1's quote. Loop on it, and add product to your customer 2's quote.
answered Dec 11 '16 at 22:49
SonySony
397312
397312
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
add a comment |
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
Yes that could be one of the solution. can you post some code snippet. Actually I have complex bundle products with many options, so I guess doing that would be quite difficult. Can you post some code to verify your logic. THanks
– aton1004
Dec 12 '16 at 9:01
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f149798%2fcan-not-update-quote-id-field-of-quote-item-table-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What I don't understand is why you want to add this item in one person's cart to another user.
– camdixon
Dec 11 '16 at 21:18
That's my requirement.actually one customer should be able to assign products to another customer cart.
– aton1004
Dec 12 '16 at 9:02