Magento2 : How to get product custom option Title from its IDGet all Custom OptionCustom Option text field value from order idMagento2 : How to add a new product custom option type?Retrieve product custom optionAdd new drop-down custom option typeFetch a custom Product Option from the titleMagento 2 custom option not showing created programmaticallyEditing Title of Existing Custom OptionHow to get custom option value and title from ids in magento 2

Will this tire fail its MOT?

A verb to describe specific positioning of three layers

How could an animal "smell" carbon monoxide?

Vienna To Graz By Rail

How fast does a character need to move to be effectively invisible?

Intel 8080-based home computers

Why is Google approaching my VPS machine?

Sending a photo of my bank account card to the future employer

Is it ethical for a company to ask its employees to move furniture on a weekend?

How can electric field be defined as force per charge, if the charge makes its own, singular electric field?

How to remove the first colon ':' from a timestamp?

How to find location on Cambridge-Mildenhall railway that still has tracks/rails?

What is the point of a constraint expression on a non-templated function?

Is it okay for a chapter's POV to shift as it progresses?

What is the meaning of [[:space:]] in bash?

How can I help our ranger feel special about her beast companion?

Jump back to the position I started a search

How was Peter Parker able to use EDITH in the end?

Is there an English equivalent for "Les carottes sont cuites", while keeping the vegetable reference?

What does it actually mean to have two time dimensions?

Is there a typesafe way to get a Database.QueryLocator?

Is the purpose of sheet music to be played along to? Or a guide for learning and reference during playing?

Is this Android phone Android 9.0 or Android 6.0?

Interviewing with an unmentioned 9 months of sick leave taken during a job



Magento2 : How to get product custom option Title from its ID


Get all Custom OptionCustom Option text field value from order idMagento2 : How to add a new product custom option type?Retrieve product custom optionAdd new drop-down custom option typeFetch a custom Product Option from the titleMagento 2 custom option not showing created programmaticallyEditing Title of Existing Custom OptionHow to get custom option value and title from ids in magento 2






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








0















In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...



$option_id=13;
$option_Title=$this->..->getTitle($option_id);









share|improve this question






























    0















    In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...



    $option_id=13;
    $option_Title=$this->..->getTitle($option_id);









    share|improve this question


























      0












      0








      0








      In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...



      $option_id=13;
      $option_Title=$this->..->getTitle($option_id);









      share|improve this question
















      In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...



      $option_id=13;
      $option_Title=$this->..->getTitle($option_id);






      magento2 custom-options title






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 6 '18 at 7:54









      Murtuza Zabuawala

      12.6k7 gold badges33 silver badges63 bronze badges




      12.6k7 gold badges33 silver badges63 bronze badges










      asked Aug 3 '17 at 7:06









      AlexglvrAlexglvr

      8901 gold badge11 silver badges39 bronze badges




      8901 gold badge11 silver badges39 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can do this with collection, my solution:



          protected $_storeManager;
          protected $_options;

          public function __construct(
          MagentoFrameworkViewElementTemplateContext $context,
          MagentoBundleModelResourceModelOptionCollectionFactory $options,
          MagentoStoreModelStoreManagerInterface $_storeManager
          )
          $this->_storeManager = $_storeManager;
          $this->_options = $options;
          parent::__construct($context);


          public function getOption($optionId)
          return $this->appendSelections(
          $this->_options->create()
          ->addFieldToFilter('option_id', $optionId)
          ->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
          ->joinValues($this->_storeManager->getStore()->getId()) // this will append title
          ->getFirstItem(),
          $this->getProduct()
          );

          protected function appendSelections(MagentoBundleModelOption $option, $product)
          if($option->getOptionId())
          $typeInstance = $product->getTypeInstance();
          $selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
          $option->setData('selections', $selections);

          return $option;



          With "Repository":



          $this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
          $productSku,
          $optionId
          );


          This solution for bundle options but in custom options will be similar...






          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%2f187640%2fmagento2-how-to-get-product-custom-option-title-from-its-id%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 do this with collection, my solution:



            protected $_storeManager;
            protected $_options;

            public function __construct(
            MagentoFrameworkViewElementTemplateContext $context,
            MagentoBundleModelResourceModelOptionCollectionFactory $options,
            MagentoStoreModelStoreManagerInterface $_storeManager
            )
            $this->_storeManager = $_storeManager;
            $this->_options = $options;
            parent::__construct($context);


            public function getOption($optionId)
            return $this->appendSelections(
            $this->_options->create()
            ->addFieldToFilter('option_id', $optionId)
            ->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
            ->joinValues($this->_storeManager->getStore()->getId()) // this will append title
            ->getFirstItem(),
            $this->getProduct()
            );

            protected function appendSelections(MagentoBundleModelOption $option, $product)
            if($option->getOptionId())
            $typeInstance = $product->getTypeInstance();
            $selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
            $option->setData('selections', $selections);

            return $option;



            With "Repository":



            $this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
            $productSku,
            $optionId
            );


            This solution for bundle options but in custom options will be similar...






            share|improve this answer





























              0














              You can do this with collection, my solution:



              protected $_storeManager;
              protected $_options;

              public function __construct(
              MagentoFrameworkViewElementTemplateContext $context,
              MagentoBundleModelResourceModelOptionCollectionFactory $options,
              MagentoStoreModelStoreManagerInterface $_storeManager
              )
              $this->_storeManager = $_storeManager;
              $this->_options = $options;
              parent::__construct($context);


              public function getOption($optionId)
              return $this->appendSelections(
              $this->_options->create()
              ->addFieldToFilter('option_id', $optionId)
              ->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
              ->joinValues($this->_storeManager->getStore()->getId()) // this will append title
              ->getFirstItem(),
              $this->getProduct()
              );

              protected function appendSelections(MagentoBundleModelOption $option, $product)
              if($option->getOptionId())
              $typeInstance = $product->getTypeInstance();
              $selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
              $option->setData('selections', $selections);

              return $option;



              With "Repository":



              $this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
              $productSku,
              $optionId
              );


              This solution for bundle options but in custom options will be similar...






              share|improve this answer



























                0












                0








                0







                You can do this with collection, my solution:



                protected $_storeManager;
                protected $_options;

                public function __construct(
                MagentoFrameworkViewElementTemplateContext $context,
                MagentoBundleModelResourceModelOptionCollectionFactory $options,
                MagentoStoreModelStoreManagerInterface $_storeManager
                )
                $this->_storeManager = $_storeManager;
                $this->_options = $options;
                parent::__construct($context);


                public function getOption($optionId)
                return $this->appendSelections(
                $this->_options->create()
                ->addFieldToFilter('option_id', $optionId)
                ->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
                ->joinValues($this->_storeManager->getStore()->getId()) // this will append title
                ->getFirstItem(),
                $this->getProduct()
                );

                protected function appendSelections(MagentoBundleModelOption $option, $product)
                if($option->getOptionId())
                $typeInstance = $product->getTypeInstance();
                $selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
                $option->setData('selections', $selections);

                return $option;



                With "Repository":



                $this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
                $productSku,
                $optionId
                );


                This solution for bundle options but in custom options will be similar...






                share|improve this answer















                You can do this with collection, my solution:



                protected $_storeManager;
                protected $_options;

                public function __construct(
                MagentoFrameworkViewElementTemplateContext $context,
                MagentoBundleModelResourceModelOptionCollectionFactory $options,
                MagentoStoreModelStoreManagerInterface $_storeManager
                )
                $this->_storeManager = $_storeManager;
                $this->_options = $options;
                parent::__construct($context);


                public function getOption($optionId)
                return $this->appendSelections(
                $this->_options->create()
                ->addFieldToFilter('option_id', $optionId)
                ->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
                ->joinValues($this->_storeManager->getStore()->getId()) // this will append title
                ->getFirstItem(),
                $this->getProduct()
                );

                protected function appendSelections(MagentoBundleModelOption $option, $product)
                if($option->getOptionId())
                $typeInstance = $product->getTypeInstance();
                $selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
                $option->setData('selections', $selections);

                return $option;



                With "Repository":



                $this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
                $productSku,
                $optionId
                );


                This solution for bundle options but in custom options will be similar...







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 1 '17 at 2:33

























                answered Oct 22 '17 at 1:50









                Slava YurthevSlava Yurthev

                828 bronze badges




                828 bronze badges



























                    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%2f187640%2fmagento2-how-to-get-product-custom-option-title-from-its-id%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

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?