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;
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
add a comment |
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
add a comment |
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
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
magento2 product product-attribute dropdown-attribute
edited May 22 at 13:31
fernandus
asked May 22 at 12:55
fernandusfernandus
14410
14410
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Should just be this
$attribute_code = 'product_type';
echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
or maybe
echo $_product->getAttributeText('product_type');
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
add a comment |
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);
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Should just be this
$attribute_code = 'product_type';
echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
or maybe
echo $_product->getAttributeText('product_type');
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
add a comment |
Should just be this
$attribute_code = 'product_type';
echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
or maybe
echo $_product->getAttributeText('product_type');
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
add a comment |
Should just be this
$attribute_code = 'product_type';
echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
or maybe
echo $_product->getAttributeText('product_type');
Should just be this
$attribute_code = 'product_type';
echo $_product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
or maybe
echo $_product->getAttributeText('product_type');
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
add a comment |
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
add a comment |
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);
add a comment |
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);
add a comment |
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);
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);
answered May 22 at 17:40
fernandusfernandus
14410
14410
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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