Get my Attribute in details.phtml file on Product Page
I need to get my Attribute code and it should be printed its values on details.phtml in my theme's template.
I have tried below but no luck.
$attribute = $_product->getResource()->getAttribute('identifier');
if ($attribute)
{
echo $attr_value = $attribute ->getFrontend()->getValue($_product);
}
Any other ideas to get this?
magento2 attributes custom-attributes
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need to get my Attribute code and it should be printed its values on details.phtml in my theme's template.
I have tried below but no luck.
$attribute = $_product->getResource()->getAttribute('identifier');
if ($attribute)
{
echo $attr_value = $attribute ->getFrontend()->getValue($_product);
}
Any other ideas to get this?
magento2 attributes custom-attributes
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need to get my Attribute code and it should be printed its values on details.phtml in my theme's template.
I have tried below but no luck.
$attribute = $_product->getResource()->getAttribute('identifier');
if ($attribute)
{
echo $attr_value = $attribute ->getFrontend()->getValue($_product);
}
Any other ideas to get this?
magento2 attributes custom-attributes
I need to get my Attribute code and it should be printed its values on details.phtml in my theme's template.
I have tried below but no luck.
$attribute = $_product->getResource()->getAttribute('identifier');
if ($attribute)
{
echo $attr_value = $attribute ->getFrontend()->getValue($_product);
}
Any other ideas to get this?
magento2 attributes custom-attributes
magento2 attributes custom-attributes
asked Jul 9 '18 at 4:08
MeskMesk
677
677
bumped to the homepage by Community♦ 9 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♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Please make sure Visible on Catalog Pages on Storefront Attribute option set as Yes.
You can check this from backend Stores >> Attributes - Products. On Attribute Edit page, check the Visible on Catalog Pages on Storefront option in Storefront Properties Tab.

I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
add a comment |
If you need to show custom attribute on product view page after sku then you can add your custom file and call this attribute.
create or edit catalog_product_view.xml file into your them and just put the bwllow code,
<referenceContainer name="product.info.stock.sku">
<block class="MagentoCatalogBlockProductView" name="product_view_style" template="Magento_Catalog::product/view/identifier.phtml" before="-"/>
</referenceContainer>
Now create identifier.phtml in appropiate path and call your custom attribute like that,
<?php
$_product = $this->getProduct();
?>
<div class="product attribute style">
<strong class="type"><?php echo __('Identifier: ')?></strong>
<div class="value" itemprop="style">
<?php echo $_product->getData('identifier') ?>
</div>
</div>
Hope it's help you.
add a comment |
Please make sure your newly created attribute from "Unassigned Attributes" to placed under "Product Details" listing in "Attribut Set".
You can check through STORES >> ATTRIBUTES >> Attribute Sets
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%2f232792%2fget-my-attribute-in-details-phtml-file-on-product-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please make sure Visible on Catalog Pages on Storefront Attribute option set as Yes.
You can check this from backend Stores >> Attributes - Products. On Attribute Edit page, check the Visible on Catalog Pages on Storefront option in Storefront Properties Tab.

I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
add a comment |
Please make sure Visible on Catalog Pages on Storefront Attribute option set as Yes.
You can check this from backend Stores >> Attributes - Products. On Attribute Edit page, check the Visible on Catalog Pages on Storefront option in Storefront Properties Tab.

I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
add a comment |
Please make sure Visible on Catalog Pages on Storefront Attribute option set as Yes.
You can check this from backend Stores >> Attributes - Products. On Attribute Edit page, check the Visible on Catalog Pages on Storefront option in Storefront Properties Tab.

Please make sure Visible on Catalog Pages on Storefront Attribute option set as Yes.
You can check this from backend Stores >> Attributes - Products. On Attribute Edit page, check the Visible on Catalog Pages on Storefront option in Storefront Properties Tab.

answered Jul 9 '18 at 4:22
Pankaj PareekPankaj Pareek
2,47411338
2,47411338
I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
add a comment |
I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
I have already set Attribute option set as Yes
– Mesk
Jul 9 '18 at 4:27
add a comment |
If you need to show custom attribute on product view page after sku then you can add your custom file and call this attribute.
create or edit catalog_product_view.xml file into your them and just put the bwllow code,
<referenceContainer name="product.info.stock.sku">
<block class="MagentoCatalogBlockProductView" name="product_view_style" template="Magento_Catalog::product/view/identifier.phtml" before="-"/>
</referenceContainer>
Now create identifier.phtml in appropiate path and call your custom attribute like that,
<?php
$_product = $this->getProduct();
?>
<div class="product attribute style">
<strong class="type"><?php echo __('Identifier: ')?></strong>
<div class="value" itemprop="style">
<?php echo $_product->getData('identifier') ?>
</div>
</div>
Hope it's help you.
add a comment |
If you need to show custom attribute on product view page after sku then you can add your custom file and call this attribute.
create or edit catalog_product_view.xml file into your them and just put the bwllow code,
<referenceContainer name="product.info.stock.sku">
<block class="MagentoCatalogBlockProductView" name="product_view_style" template="Magento_Catalog::product/view/identifier.phtml" before="-"/>
</referenceContainer>
Now create identifier.phtml in appropiate path and call your custom attribute like that,
<?php
$_product = $this->getProduct();
?>
<div class="product attribute style">
<strong class="type"><?php echo __('Identifier: ')?></strong>
<div class="value" itemprop="style">
<?php echo $_product->getData('identifier') ?>
</div>
</div>
Hope it's help you.
add a comment |
If you need to show custom attribute on product view page after sku then you can add your custom file and call this attribute.
create or edit catalog_product_view.xml file into your them and just put the bwllow code,
<referenceContainer name="product.info.stock.sku">
<block class="MagentoCatalogBlockProductView" name="product_view_style" template="Magento_Catalog::product/view/identifier.phtml" before="-"/>
</referenceContainer>
Now create identifier.phtml in appropiate path and call your custom attribute like that,
<?php
$_product = $this->getProduct();
?>
<div class="product attribute style">
<strong class="type"><?php echo __('Identifier: ')?></strong>
<div class="value" itemprop="style">
<?php echo $_product->getData('identifier') ?>
</div>
</div>
Hope it's help you.
If you need to show custom attribute on product view page after sku then you can add your custom file and call this attribute.
create or edit catalog_product_view.xml file into your them and just put the bwllow code,
<referenceContainer name="product.info.stock.sku">
<block class="MagentoCatalogBlockProductView" name="product_view_style" template="Magento_Catalog::product/view/identifier.phtml" before="-"/>
</referenceContainer>
Now create identifier.phtml in appropiate path and call your custom attribute like that,
<?php
$_product = $this->getProduct();
?>
<div class="product attribute style">
<strong class="type"><?php echo __('Identifier: ')?></strong>
<div class="value" itemprop="style">
<?php echo $_product->getData('identifier') ?>
</div>
</div>
Hope it's help you.
answered Jul 9 '18 at 4:38
DhruminDhrumin
496418
496418
add a comment |
add a comment |
Please make sure your newly created attribute from "Unassigned Attributes" to placed under "Product Details" listing in "Attribut Set".
You can check through STORES >> ATTRIBUTES >> Attribute Sets
add a comment |
Please make sure your newly created attribute from "Unassigned Attributes" to placed under "Product Details" listing in "Attribut Set".
You can check through STORES >> ATTRIBUTES >> Attribute Sets
add a comment |
Please make sure your newly created attribute from "Unassigned Attributes" to placed under "Product Details" listing in "Attribut Set".
You can check through STORES >> ATTRIBUTES >> Attribute Sets
Please make sure your newly created attribute from "Unassigned Attributes" to placed under "Product Details" listing in "Attribut Set".
You can check through STORES >> ATTRIBUTES >> Attribute Sets
answered Jul 9 '18 at 4:46
Sanjay VadadoriyaSanjay Vadadoriya
767
767
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%2f232792%2fget-my-attribute-in-details-phtml-file-on-product-page%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