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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form