How to get dropdown product attribute value Magento2How can I load a product attribute from its flat table into a product object?Magento 2 : How to get the product attributes based on attribute set id on listing pageGet product collection based on custom attribute (drop down attribute value)Getting value from product attributes in Magento 2Media image attribute bugged in frontendHow to get value of TextField Attribute in Magento 2 in .phtml?How to get configurable attribute label and value in magento 2?Magento 2 : How can I display an attribute on the category page?Widget/block code in product custom attribute not rendering at front-end magento 2.2.5Layered Navigation: Create Attribute Options for Drop Down During New Product Import

Can the Help action be used to give advantage to a specific ally's attack (rather than just the next ally who attacks the target)?

How current works

What are these (utility?) boxes at the side of the house?

Restoring order in a deck of playing cards

In what episode of TOS did a character on the bridge make a comment about raising one to some power?

How many chess players are over 2500 Elo?

Mother abusing my finances

What F1 in name of seeds/varieties means?

Which noble houses were destroyed during the Game of Thrones?

1960s sci-fi novella with a character who is treated as invisible by being ignored

What was this black-and-white film set in the Arctic or Antarctic where the monster/alien gets fried in the end?

Scaffoldings in New York

Why does the 6502 have the BIT instruction?

Is this story about US tax office reasonable?

What are the problems in teaching guitar via Skype?

Probability of fraction not being able to be simplified

How were these pictures of spacecraft wind tunnel testing taken?

Is there any use case for the bottom type as a function parameter type?

How feasible is the Delta-Glider?

Modern approach to radio buttons

What is the best linguistic term for describing the kw > p / gw > b change, and its usual companion s > h

What does it mean when you think without speaking?

Where can I find the list of all tendons in the human body?

Is this light switch installation safe and legal?



How to get dropdown product attribute value Magento2


How can I load a product attribute from its flat table into a product object?Magento 2 : How to get the product attributes based on attribute set id on listing pageGet product collection based on custom attribute (drop down attribute value)Getting value from product attributes in Magento 2Media image attribute bugged in frontendHow to get value of TextField Attribute in Magento 2 in .phtml?How to get configurable attribute label and value in magento 2?Magento 2 : How can I display an attribute on the category page?Widget/block code in product custom attribute not rendering at front-end magento 2.2.5Layered Navigation: Create Attribute Options for Drop Down During New Product Import






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








0















I have created a product drop-down attribute and assigned a value to it on the product.



I need them on product detail page.



$_attributeValue = $_product->getResource()->getAttribute('product_type')->setStoreId(0)->getFrontend()->getValue($_product);
echo $_attributeValue;


OR



$_attributeValue = $_product->getResource()->getAttribute('product_type')->getFrontend()->getValue($_product);
echo $_attributeValue;


Output as




NO




On print($_attributeValue) my output



MagentoFrameworkPhrase Object ( [text:MagentoFrameworkPhrase:private] => No [arguments:MagentoFrameworkPhrase:private] => Array ( ) )



But for product text attribute I get the output.










share|improve this question






























    0















    I have created a product drop-down attribute and assigned a value to it on the product.



    I need them on product detail page.



    $_attributeValue = $_product->getResource()->getAttribute('product_type')->setStoreId(0)->getFrontend()->getValue($_product);
    echo $_attributeValue;


    OR



    $_attributeValue = $_product->getResource()->getAttribute('product_type')->getFrontend()->getValue($_product);
    echo $_attributeValue;


    Output as




    NO




    On print($_attributeValue) my output



    MagentoFrameworkPhrase Object ( [text:MagentoFrameworkPhrase:private] => No [arguments:MagentoFrameworkPhrase:private] => Array ( ) )



    But for product text attribute I get the output.










    share|improve this question


























      0












      0








      0








      I have created a product drop-down attribute and assigned a value to it on the product.



      I need them on product detail page.



      $_attributeValue = $_product->getResource()->getAttribute('product_type')->setStoreId(0)->getFrontend()->getValue($_product);
      echo $_attributeValue;


      OR



      $_attributeValue = $_product->getResource()->getAttribute('product_type')->getFrontend()->getValue($_product);
      echo $_attributeValue;


      Output as




      NO




      On print($_attributeValue) my output



      MagentoFrameworkPhrase Object ( [text:MagentoFrameworkPhrase:private] => No [arguments:MagentoFrameworkPhrase:private] => Array ( ) )



      But for product text attribute I get the output.










      share|improve this question
















      I have created a product drop-down attribute and assigned a value to it on the product.



      I need them on product detail page.



      $_attributeValue = $_product->getResource()->getAttribute('product_type')->setStoreId(0)->getFrontend()->getValue($_product);
      echo $_attributeValue;


      OR



      $_attributeValue = $_product->getResource()->getAttribute('product_type')->getFrontend()->getValue($_product);
      echo $_attributeValue;


      Output as




      NO




      On print($_attributeValue) my output



      MagentoFrameworkPhrase Object ( [text:MagentoFrameworkPhrase:private] => No [arguments:MagentoFrameworkPhrase:private] => Array ( ) )



      But for product text attribute I get the output.







      magento2 product product-attribute dropdown-attribute






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 22 at 13:31







      fernandus

















      asked May 22 at 12:55









      fernandusfernandus

      14410




      14410




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Should just be this



          $attribute_code = 'product_type';
          echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);


          or maybe



          echo $_product->getAttributeText('product_type');





          share|improve this answer























          • The first code returns No and second one empty, This code also works for product text attribute.

            – fernandus
            May 22 at 13:16











          • $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

            – fernandus
            May 22 at 13:19











          • I have updated my question

            – fernandus
            May 22 at 13:32











          • ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

            – fernandus
            May 22 at 13:39











          • I am not getting for color dropdown attribute in too

            – fernandus
            May 22 at 14:26



















          0














          I tried to get the product from item which dint work for me



          $product = $_item->getProduct();
          $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);


          This one works



          $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
          $product = $objectManager->get('MagentoCatalogModelProduct')->load($_item->getProductId());
          $product_type = $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);





          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%2f275689%2fhow-to-get-dropdown-product-attribute-value-magento2%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














            Should just be this



            $attribute_code = 'product_type';
            echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);


            or maybe



            echo $_product->getAttributeText('product_type');





            share|improve this answer























            • The first code returns No and second one empty, This code also works for product text attribute.

              – fernandus
              May 22 at 13:16











            • $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

              – fernandus
              May 22 at 13:19











            • I have updated my question

              – fernandus
              May 22 at 13:32











            • ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

              – fernandus
              May 22 at 13:39











            • I am not getting for color dropdown attribute in too

              – fernandus
              May 22 at 14:26
















            0














            Should just be this



            $attribute_code = 'product_type';
            echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);


            or maybe



            echo $_product->getAttributeText('product_type');





            share|improve this answer























            • The first code returns No and second one empty, This code also works for product text attribute.

              – fernandus
              May 22 at 13:16











            • $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

              – fernandus
              May 22 at 13:19











            • I have updated my question

              – fernandus
              May 22 at 13:32











            • ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

              – fernandus
              May 22 at 13:39











            • I am not getting for color dropdown attribute in too

              – fernandus
              May 22 at 14:26














            0












            0








            0







            Should just be this



            $attribute_code = 'product_type';
            echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);


            or maybe



            echo $_product->getAttributeText('product_type');





            share|improve this answer













            Should just be this



            $attribute_code = 'product_type';
            echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);


            or maybe



            echo $_product->getAttributeText('product_type');






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 22 at 13:08









            Dominic XigenDominic Xigen

            63511




            63511












            • The first code returns No and second one empty, This code also works for product text attribute.

              – fernandus
              May 22 at 13:16











            • $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

              – fernandus
              May 22 at 13:19











            • I have updated my question

              – fernandus
              May 22 at 13:32











            • ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

              – fernandus
              May 22 at 13:39











            • I am not getting for color dropdown attribute in too

              – fernandus
              May 22 at 14:26


















            • The first code returns No and second one empty, This code also works for product text attribute.

              – fernandus
              May 22 at 13:16











            • $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

              – fernandus
              May 22 at 13:19











            • I have updated my question

              – fernandus
              May 22 at 13:32











            • ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

              – fernandus
              May 22 at 13:39











            • I am not getting for color dropdown attribute in too

              – fernandus
              May 22 at 14:26

















            The first code returns No and second one empty, This code also works for product text attribute.

            – fernandus
            May 22 at 13:16





            The first code returns No and second one empty, This code also works for product text attribute.

            – fernandus
            May 22 at 13:16













            $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

            – fernandus
            May 22 at 13:19





            $_product->getResource()->getAttribute('product_type')->getFrontendLabel() works and in product detail in more information i can see the value i have selected for code 'product_type' but dont know why this code is not working

            – fernandus
            May 22 at 13:19













            I have updated my question

            – fernandus
            May 22 at 13:32





            I have updated my question

            – fernandus
            May 22 at 13:32













            ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

            – fernandus
            May 22 at 13:39





            ->setStoreId(0) will get data based on store few blogs has this, By issue is different.

            – fernandus
            May 22 at 13:39













            I am not getting for color dropdown attribute in too

            – fernandus
            May 22 at 14:26






            I am not getting for color dropdown attribute in too

            – fernandus
            May 22 at 14:26














            0














            I tried to get the product from item which dint work for me



            $product = $_item->getProduct();
            $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);


            This one works



            $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
            $product = $objectManager->get('MagentoCatalogModelProduct')->load($_item->getProductId());
            $product_type = $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);





            share|improve this answer



























              0














              I tried to get the product from item which dint work for me



              $product = $_item->getProduct();
              $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);


              This one works



              $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
              $product = $objectManager->get('MagentoCatalogModelProduct')->load($_item->getProductId());
              $product_type = $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);





              share|improve this answer

























                0












                0








                0







                I tried to get the product from item which dint work for me



                $product = $_item->getProduct();
                $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);


                This one works



                $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
                $product = $objectManager->get('MagentoCatalogModelProduct')->load($_item->getProductId());
                $product_type = $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);





                share|improve this answer













                I tried to get the product from item which dint work for me



                $product = $_item->getProduct();
                $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);


                This one works



                $objectManager = MagentoFrameworkAppObjectManager::getInstance(); 
                $product = $objectManager->get('MagentoCatalogModelProduct')->load($_item->getProductId());
                $product_type = $product->getResource()->getAttribute('product_type')->getFrontend()->getValue($product);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 22 at 17:40









                fernandusfernandus

                14410




                14410



























                    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%2f275689%2fhow-to-get-dropdown-product-attribute-value-magento2%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?