Get Configurable Parent from simple product in quote when simple product has multiple parents





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















So I have a client that has about 14 Configurable products that are basically the same thing (logo item). Then they have created a simple product for each base color(Blue, Pink, Black)[3 total simple products]. They have then taken the 3 simple products and assigned each of them to the 14 configurable products so that the logo from the configurable products gets the base color simple product selected.



In their setup the configurable products house the images for these products. However, since you can only purchase the simple product the image that is being select is ALWAYS coming over as the image from product 1 of 20 (lowest product_id), no matter which selection is chosen.



The code im going to be trying to update is in a custom block that is being used on the checkout_onepage_index reference.



My question is:




From the sales/quote_item Model, how can I determine exactly which parent the
child item was selected from?




or




From the checkout/cart Model, can something be achieved?








Things I have already seen but are not really helpful.



Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId())

result

Array
(
[0] => 45207
[1] => 45209
[2] => 45210
[3] => 45211
[4] => 45212
[5] => 45213
[6] => 45214
[7] => 45215
[8] => 45216
[9] => 45217
[10] => 45218
[11] => 45219
[12] => 45220
[13] => 45222
)



  • This just returns an array of all parentIds for the child item. Which is great, but there is no indication of which Parent Product this simple product was selected from.










share|improve this question














bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    0















    So I have a client that has about 14 Configurable products that are basically the same thing (logo item). Then they have created a simple product for each base color(Blue, Pink, Black)[3 total simple products]. They have then taken the 3 simple products and assigned each of them to the 14 configurable products so that the logo from the configurable products gets the base color simple product selected.



    In their setup the configurable products house the images for these products. However, since you can only purchase the simple product the image that is being select is ALWAYS coming over as the image from product 1 of 20 (lowest product_id), no matter which selection is chosen.



    The code im going to be trying to update is in a custom block that is being used on the checkout_onepage_index reference.



    My question is:




    From the sales/quote_item Model, how can I determine exactly which parent the
    child item was selected from?




    or




    From the checkout/cart Model, can something be achieved?








    Things I have already seen but are not really helpful.



    Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId())

    result

    Array
    (
    [0] => 45207
    [1] => 45209
    [2] => 45210
    [3] => 45211
    [4] => 45212
    [5] => 45213
    [6] => 45214
    [7] => 45215
    [8] => 45216
    [9] => 45217
    [10] => 45218
    [11] => 45219
    [12] => 45220
    [13] => 45222
    )



    • This just returns an array of all parentIds for the child item. Which is great, but there is no indication of which Parent Product this simple product was selected from.










    share|improve this question














    bumped to the homepage by Community 12 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      So I have a client that has about 14 Configurable products that are basically the same thing (logo item). Then they have created a simple product for each base color(Blue, Pink, Black)[3 total simple products]. They have then taken the 3 simple products and assigned each of them to the 14 configurable products so that the logo from the configurable products gets the base color simple product selected.



      In their setup the configurable products house the images for these products. However, since you can only purchase the simple product the image that is being select is ALWAYS coming over as the image from product 1 of 20 (lowest product_id), no matter which selection is chosen.



      The code im going to be trying to update is in a custom block that is being used on the checkout_onepage_index reference.



      My question is:




      From the sales/quote_item Model, how can I determine exactly which parent the
      child item was selected from?




      or




      From the checkout/cart Model, can something be achieved?








      Things I have already seen but are not really helpful.



      Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId())

      result

      Array
      (
      [0] => 45207
      [1] => 45209
      [2] => 45210
      [3] => 45211
      [4] => 45212
      [5] => 45213
      [6] => 45214
      [7] => 45215
      [8] => 45216
      [9] => 45217
      [10] => 45218
      [11] => 45219
      [12] => 45220
      [13] => 45222
      )



      • This just returns an array of all parentIds for the child item. Which is great, but there is no indication of which Parent Product this simple product was selected from.










      share|improve this question














      So I have a client that has about 14 Configurable products that are basically the same thing (logo item). Then they have created a simple product for each base color(Blue, Pink, Black)[3 total simple products]. They have then taken the 3 simple products and assigned each of them to the 14 configurable products so that the logo from the configurable products gets the base color simple product selected.



      In their setup the configurable products house the images for these products. However, since you can only purchase the simple product the image that is being select is ALWAYS coming over as the image from product 1 of 20 (lowest product_id), no matter which selection is chosen.



      The code im going to be trying to update is in a custom block that is being used on the checkout_onepage_index reference.



      My question is:




      From the sales/quote_item Model, how can I determine exactly which parent the
      child item was selected from?




      or




      From the checkout/cart Model, can something be achieved?








      Things I have already seen but are not really helpful.



      Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId())

      result

      Array
      (
      [0] => 45207
      [1] => 45209
      [2] => 45210
      [3] => 45211
      [4] => 45212
      [5] => 45213
      [6] => 45214
      [7] => 45215
      [8] => 45216
      [9] => 45217
      [10] => 45218
      [11] => 45219
      [12] => 45220
      [13] => 45222
      )



      • This just returns an array of all parentIds for the child item. Which is great, but there is no indication of which Parent Product this simple product was selected from.







      magento-1.9 configurable-product cart blocks quoteitem






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 20 '17 at 17:29









      OuchyOuchy

      13




      13





      bumped to the homepage by Community 12 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 12 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You Can set parent id in info buy request when you add an item to cart. Which is saved in sales_flat_quote_item_options. Below is the code which you use to add additional info to your item:



          $params = array(
          'parent_id'=> (int)$parent_id
          );
          $request = new Varien_Object();
          $request->setData($params);

          $result = $quote->addProduct($product, $request);


          To retrieve this information you can use the below code:



          $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
          print_r($options['info_buyRequest']['parent_id']);





          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%2f155760%2fget-configurable-parent-from-simple-product-in-quote-when-simple-product-has-mul%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









            0














            You Can set parent id in info buy request when you add an item to cart. Which is saved in sales_flat_quote_item_options. Below is the code which you use to add additional info to your item:



            $params = array(
            'parent_id'=> (int)$parent_id
            );
            $request = new Varien_Object();
            $request->setData($params);

            $result = $quote->addProduct($product, $request);


            To retrieve this information you can use the below code:



            $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
            print_r($options['info_buyRequest']['parent_id']);





            share|improve this answer




























              0














              You Can set parent id in info buy request when you add an item to cart. Which is saved in sales_flat_quote_item_options. Below is the code which you use to add additional info to your item:



              $params = array(
              'parent_id'=> (int)$parent_id
              );
              $request = new Varien_Object();
              $request->setData($params);

              $result = $quote->addProduct($product, $request);


              To retrieve this information you can use the below code:



              $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
              print_r($options['info_buyRequest']['parent_id']);





              share|improve this answer


























                0












                0








                0







                You Can set parent id in info buy request when you add an item to cart. Which is saved in sales_flat_quote_item_options. Below is the code which you use to add additional info to your item:



                $params = array(
                'parent_id'=> (int)$parent_id
                );
                $request = new Varien_Object();
                $request->setData($params);

                $result = $quote->addProduct($product, $request);


                To retrieve this information you can use the below code:



                $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
                print_r($options['info_buyRequest']['parent_id']);





                share|improve this answer













                You Can set parent id in info buy request when you add an item to cart. Which is saved in sales_flat_quote_item_options. Below is the code which you use to add additional info to your item:



                $params = array(
                'parent_id'=> (int)$parent_id
                );
                $request = new Varien_Object();
                $request->setData($params);

                $result = $quote->addProduct($product, $request);


                To retrieve this information you can use the below code:



                $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
                print_r($options['info_buyRequest']['parent_id']);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 20 '18 at 21:01









                EllisonEllison

                11




                11






























                    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%2f155760%2fget-configurable-parent-from-simple-product-in-quote-when-simple-product-has-mul%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

                    What other Star Trek series did the main TNG cast show up in?

                    Berlina muro

                    Berlina aerponto