Magento 2.3 - Add product to cart issue with store viewAdd to Cart via AJAX - should I add a configurable product with options or a simple product?add to cart products with max qty of products error with run scriptMagento 2 Add to cart one product with different size at once but seems as one productHow to prevent Magento from removing disabled items from cart?Programmatically adding product to cart returns empty cartMagento 1.9 : Programmatically created cart not showing on frontendMagento 2: Add a product to the cart programmaticallyYou need to choose options for your item while adding product to cartAdd product to quote in admin programmatically magento 2Magento 2 add products to cart by using code?

When were female captains banned from Starfleet?

What exact color does ozone gas have?

Why would a new[] expression ever invoke a destructor?

It grows, but water kills it

Non-trope happy ending?

Mimic lecturing on blackboard, facing audience

Add big quotation marks inside my colorbox

Why is so much work done on numerical verification of the Riemann Hypothesis?

What are the advantages of simplicial model categories over non-simplicial ones?

How to rewrite equation of hyperbola in standard form

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Quoting Keynes in a lecture

What happens if you are holding an Iron Flask with a demon inside and walk into an Antimagic Field?

Does IPv6 have similar concept of network mask?

What is going on with 'gets(stdin)' on the site coderbyte?

How much character growth crosses the line into breaking the character

What if a revenant (monster) gains fire resistance?

How can I write humor as character trait?

Why does a simple loop result in ASYNC_NETWORK_IO waits?

How to explain what's wrong with this application of the chain rule?

Is aluminum electrical wire used on aircraft?

Keeping a ball lost forever

Review your own paper in Mathematics

Picking the different solutions to the time independent Schrodinger eqaution



Magento 2.3 - Add product to cart issue with store view


Add to Cart via AJAX - should I add a configurable product with options or a simple product?add to cart products with max qty of products error with run scriptMagento 2 Add to cart one product with different size at once but seems as one productHow to prevent Magento from removing disabled items from cart?Programmatically adding product to cart returns empty cartMagento 1.9 : Programmatically created cart not showing on frontendMagento 2: Add a product to the cart programmaticallyYou need to choose options for your item while adding product to cartAdd product to quote in admin programmatically magento 2Magento 2 add products to cart by using code?













1















I have two stores with id 1 and 2. Am trying to add product programmatically using below code
$params = array(
'form_key' => $this->_formkey->getFormKey(),
'product' => $productId, //product Id
'qty' => $qty //quantity of product

);

$this->_cart->addProduct($product_coll, $params);
$this->_cart->save();



Checkout flow works well for the store 1.
But for store 2, when I add any product to cart using above script. It is adding it to the store 1. I found out this when I looked into the magento quote table . Even though am in store 2, when i add product to cart the quote tables shows it is assigned to store 1.
So the order was also place in store 1 instead of store 2.



Can anyone please help me with this ASAP?










share|improve this question


























    1















    I have two stores with id 1 and 2. Am trying to add product programmatically using below code
    $params = array(
    'form_key' => $this->_formkey->getFormKey(),
    'product' => $productId, //product Id
    'qty' => $qty //quantity of product

    );

    $this->_cart->addProduct($product_coll, $params);
    $this->_cart->save();



    Checkout flow works well for the store 1.
    But for store 2, when I add any product to cart using above script. It is adding it to the store 1. I found out this when I looked into the magento quote table . Even though am in store 2, when i add product to cart the quote tables shows it is assigned to store 1.
    So the order was also place in store 1 instead of store 2.



    Can anyone please help me with this ASAP?










    share|improve this question
























      1












      1








      1








      I have two stores with id 1 and 2. Am trying to add product programmatically using below code
      $params = array(
      'form_key' => $this->_formkey->getFormKey(),
      'product' => $productId, //product Id
      'qty' => $qty //quantity of product

      );

      $this->_cart->addProduct($product_coll, $params);
      $this->_cart->save();



      Checkout flow works well for the store 1.
      But for store 2, when I add any product to cart using above script. It is adding it to the store 1. I found out this when I looked into the magento quote table . Even though am in store 2, when i add product to cart the quote tables shows it is assigned to store 1.
      So the order was also place in store 1 instead of store 2.



      Can anyone please help me with this ASAP?










      share|improve this question














      I have two stores with id 1 and 2. Am trying to add product programmatically using below code
      $params = array(
      'form_key' => $this->_formkey->getFormKey(),
      'product' => $productId, //product Id
      'qty' => $qty //quantity of product

      );

      $this->_cart->addProduct($product_coll, $params);
      $this->_cart->save();



      Checkout flow works well for the store 1.
      But for store 2, when I add any product to cart using above script. It is adding it to the store 1. I found out this when I looked into the magento quote table . Even though am in store 2, when i add product to cart the quote tables shows it is assigned to store 1.
      So the order was also place in store 1 instead of store 2.



      Can anyone please help me with this ASAP?







      magento2 orders multistore addtocart quote






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      Prabhu M.Prabhu M.

      258




      258




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Set store id when get product



          $product_coll=$this->productRepository->getById($productId, false, $storeId)





          share|improve this answer























          • Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

            – Prabhu M.
            18 hours ago











          • Is custom REST API is always in default scope? How shall I make that to other stores scope?

            – Prabhu M.
            14 hours ago


















          0














          I was using my custom REST API to add, fetch and remove the products to and from cart.



          The problem was I didn't specify the Scope section in the REST API url as per the Magento Documentation



          https://devdocs.magento.com/guides/v2.3/rest/tutorials/index.html



          <HTTP verb> http://<host>/rest/<scope>/<endpoint>



          In place of scope we should pass our store code






          share|improve this answer
























            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266853%2fmagento-2-3-add-product-to-cart-issue-with-store-view%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Set store id when get product



            $product_coll=$this->productRepository->getById($productId, false, $storeId)





            share|improve this answer























            • Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

              – Prabhu M.
              18 hours ago











            • Is custom REST API is always in default scope? How shall I make that to other stores scope?

              – Prabhu M.
              14 hours ago















            0














            Set store id when get product



            $product_coll=$this->productRepository->getById($productId, false, $storeId)





            share|improve this answer























            • Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

              – Prabhu M.
              18 hours ago











            • Is custom REST API is always in default scope? How shall I make that to other stores scope?

              – Prabhu M.
              14 hours ago













            0












            0








            0







            Set store id when get product



            $product_coll=$this->productRepository->getById($productId, false, $storeId)





            share|improve this answer













            Set store id when get product



            $product_coll=$this->productRepository->getById($productId, false, $storeId)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            Pragnadeep PitrodaPragnadeep Pitroda

            566




            566












            • Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

              – Prabhu M.
              18 hours ago











            • Is custom REST API is always in default scope? How shall I make that to other stores scope?

              – Prabhu M.
              14 hours ago

















            • Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

              – Prabhu M.
              18 hours ago











            • Is custom REST API is always in default scope? How shall I make that to other stores scope?

              – Prabhu M.
              14 hours ago
















            Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

            – Prabhu M.
            18 hours ago





            Actually am using custom REST API to add products to cart and to fetch all the cart items. When I return the store id from that API it return only the default store_id as 1 even if i'm in store 2. Can you please tell me what error i would have done during the custom API creation?

            – Prabhu M.
            18 hours ago













            Is custom REST API is always in default scope? How shall I make that to other stores scope?

            – Prabhu M.
            14 hours ago





            Is custom REST API is always in default scope? How shall I make that to other stores scope?

            – Prabhu M.
            14 hours ago













            0














            I was using my custom REST API to add, fetch and remove the products to and from cart.



            The problem was I didn't specify the Scope section in the REST API url as per the Magento Documentation



            https://devdocs.magento.com/guides/v2.3/rest/tutorials/index.html



            <HTTP verb> http://<host>/rest/<scope>/<endpoint>



            In place of scope we should pass our store code






            share|improve this answer





























              0














              I was using my custom REST API to add, fetch and remove the products to and from cart.



              The problem was I didn't specify the Scope section in the REST API url as per the Magento Documentation



              https://devdocs.magento.com/guides/v2.3/rest/tutorials/index.html



              <HTTP verb> http://<host>/rest/<scope>/<endpoint>



              In place of scope we should pass our store code






              share|improve this answer



























                0












                0








                0







                I was using my custom REST API to add, fetch and remove the products to and from cart.



                The problem was I didn't specify the Scope section in the REST API url as per the Magento Documentation



                https://devdocs.magento.com/guides/v2.3/rest/tutorials/index.html



                <HTTP verb> http://<host>/rest/<scope>/<endpoint>



                In place of scope we should pass our store code






                share|improve this answer















                I was using my custom REST API to add, fetch and remove the products to and from cart.



                The problem was I didn't specify the Scope section in the REST API url as per the Magento Documentation



                https://devdocs.magento.com/guides/v2.3/rest/tutorials/index.html



                <HTTP verb> http://<host>/rest/<scope>/<endpoint>



                In place of scope we should pass our store code







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 13 hours ago

























                answered 13 hours ago









                Prabhu M.Prabhu M.

                258




                258



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266853%2fmagento-2-3-add-product-to-cart-issue-with-store-view%23new-answer', 'question_page');

                    );

                    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







                    Popular posts from this blog

                    Sum ergo cogito? 1 nng

                    419 nièngy_Soadمي 19bal1.5o_g

                    Queiggey Chernihivv 9NnOo i Zw X QqKk LpB