Magento2 Showing a custom attribute on category listing pageMagento2.1 - Show custom category attribute on frontendCustom attribute values Not showing while compare the product in magento2Unset custom data from product attributeGetting Custom Product Attribute Value via objectManager in Magento 2How to show custom product attribute in Items orderd tab Magento 1.9.3Cannot save product with required custom attribute (unique value)Magento2 - Add custom attribute in transactional sales e-mailHow to show product custom attribute in items ordered section in magento2.2.0?Magento 2 get custom attribute of a single product inside a pluginMagento 2 plugin change price of products that have a custom attribute with
What is the relationship between spectral sequences and obstruction theory?
Checks user level and limit the data before saving it to mongoDB
Is DC-DC (24v to 12v) Buck Conversion typically more efficient than AC-DC (110v to 12v) conversion?
How exactly does Hawking radiation decrease the mass of black holes?
If a warlock with the Repelling Blast invocation casts Eldritch Blast and hits, must the targets always be pushed back?
How did Captain America manage to do this?
Does this extra sentence in the description of the warlock's Eyes of the Rune Keeper eldritch invocation appear in any official reference?
How come there are so many candidates for the 2020 Democratic party presidential nomination?
How could Tony Stark make this in Endgame?
Is there a way to get a compiler for the original B programming language?
Term for maladaptive animal behavior that will lead to their demise?
Examples of non trivial equivalence relations , I mean equivalence relations without the expression " same ... as" in their definition?
Uniformly continuous derivative implies existence of limit
What happened to Captain America in Endgame?
Fizzy, soft, pop and still drinks
What is the incentive for curl to release the library for free?
How to stop co-workers from teasing me because I know Russian?
Stop and Take a Breath!
The Defining Moment
What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?
How to make a pipeline wait for end-of-file or stop after an error?
Is contacting this expert in the field something acceptable or would it be discourteous?
Can someone publish a story that happened to you?
Critique of timeline aesthetic
Magento2 Showing a custom attribute on category listing page
Magento2.1 - Show custom category attribute on frontendCustom attribute values Not showing while compare the product in magento2Unset custom data from product attributeGetting Custom Product Attribute Value via objectManager in Magento 2How to show custom product attribute in Items orderd tab Magento 1.9.3Cannot save product with required custom attribute (unique value)Magento2 - Add custom attribute in transactional sales e-mailHow to show product custom attribute in items ordered section in magento2.2.0?Magento 2 get custom attribute of a single product inside a pluginMagento 2 plugin change price of products that have a custom attribute with
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a magento2 based website and I am wanting to show a custom attribute on the category listing page. My issue seems to be that on desktop and tablet the products are shown 3 across and on mobile they are shown 2 across.
Now if the last item in the row shouldn't show the custom attribute (or has no value set for the custom attribute) it still shows the prior products custom attribute value.
Below is my code. I know using Object Manager in the php file is not the ideal. the php file edited is
Magento_Catalog/templates/product/price/final_price.phtml
//THIS CODE WILL HELP US WRITE TEXT UNDER THE PRICE SUCH AS BOGO, ETC
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Has you can see I even tried using the unset() function before I call in the custom attribute. However no matter what I do the very next product after the product that has a value for the custom attribute if the net product does not have a value it shows the prior products value(s).
Its odd because if I do
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
$theitemskunumber_is = $_productdata->getData('sku');
echo "$theitemskunumber_is";
all the products that are last in each row show the correct sku.
Yet if I use a the same code but call in a custom attribute it doesnt show . correctly on the last item in the row?
magento2 catalog custom-attributes
add a comment |
I have a magento2 based website and I am wanting to show a custom attribute on the category listing page. My issue seems to be that on desktop and tablet the products are shown 3 across and on mobile they are shown 2 across.
Now if the last item in the row shouldn't show the custom attribute (or has no value set for the custom attribute) it still shows the prior products custom attribute value.
Below is my code. I know using Object Manager in the php file is not the ideal. the php file edited is
Magento_Catalog/templates/product/price/final_price.phtml
//THIS CODE WILL HELP US WRITE TEXT UNDER THE PRICE SUCH AS BOGO, ETC
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Has you can see I even tried using the unset() function before I call in the custom attribute. However no matter what I do the very next product after the product that has a value for the custom attribute if the net product does not have a value it shows the prior products value(s).
Its odd because if I do
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
$theitemskunumber_is = $_productdata->getData('sku');
echo "$theitemskunumber_is";
all the products that are last in each row show the correct sku.
Yet if I use a the same code but call in a custom attribute it doesnt show . correctly on the last item in the row?
magento2 catalog custom-attributes
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
javascript = js
– Sohel Rana
Apr 24 at 16:10
add a comment |
I have a magento2 based website and I am wanting to show a custom attribute on the category listing page. My issue seems to be that on desktop and tablet the products are shown 3 across and on mobile they are shown 2 across.
Now if the last item in the row shouldn't show the custom attribute (or has no value set for the custom attribute) it still shows the prior products custom attribute value.
Below is my code. I know using Object Manager in the php file is not the ideal. the php file edited is
Magento_Catalog/templates/product/price/final_price.phtml
//THIS CODE WILL HELP US WRITE TEXT UNDER THE PRICE SUCH AS BOGO, ETC
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Has you can see I even tried using the unset() function before I call in the custom attribute. However no matter what I do the very next product after the product that has a value for the custom attribute if the net product does not have a value it shows the prior products value(s).
Its odd because if I do
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
$theitemskunumber_is = $_productdata->getData('sku');
echo "$theitemskunumber_is";
all the products that are last in each row show the correct sku.
Yet if I use a the same code but call in a custom attribute it doesnt show . correctly on the last item in the row?
magento2 catalog custom-attributes
I have a magento2 based website and I am wanting to show a custom attribute on the category listing page. My issue seems to be that on desktop and tablet the products are shown 3 across and on mobile they are shown 2 across.
Now if the last item in the row shouldn't show the custom attribute (or has no value set for the custom attribute) it still shows the prior products custom attribute value.
Below is my code. I know using Object Manager in the php file is not the ideal. the php file edited is
Magento_Catalog/templates/product/price/final_price.phtml
//THIS CODE WILL HELP US WRITE TEXT UNDER THE PRICE SUCH AS BOGO, ETC
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Has you can see I even tried using the unset() function before I call in the custom attribute. However no matter what I do the very next product after the product that has a value for the custom attribute if the net product does not have a value it shows the prior products value(s).
Its odd because if I do
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->get('MagentoCatalogModelProduct')->load($productId);
$theitemskunumber_is = $_productdata->getData('sku');
echo "$theitemskunumber_is";
all the products that are last in each row show the correct sku.
Yet if I use a the same code but call in a custom attribute it doesnt show . correctly on the last item in the row?
magento2 catalog custom-attributes
magento2 catalog custom-attributes
edited Apr 24 at 16:19
Jayreis
asked Apr 24 at 15:50
JayreisJayreis
312933
312933
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
javascript = js
– Sohel Rana
Apr 24 at 16:10
add a comment |
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
javascript = js
– Sohel Rana
Apr 24 at 16:10
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
javascript = js
– Sohel Rana
Apr 24 at 16:10
javascript = js
– Sohel Rana
Apr 24 at 16:10
add a comment |
1 Answer
1
active
oldest
votes
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Note: Avoid to use object manager directly and avoid to load product that will impact your page speed.
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
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%2f272322%2fmagento2-showing-a-custom-attribute-on-category-listing-page%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
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Note: Avoid to use object manager directly and avoid to load product that will impact your page speed.
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Note: Avoid to use object manager directly and avoid to load product that will impact your page speed.
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
add a comment |
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Note: Avoid to use object manager directly and avoid to load product that will impact your page speed.
Try following way:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_productdata = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
unset($promo_text);
$promo_text = $_productdata->getData('promo_text');
$promo_text_start_date = $_productdata->getData('promo_text_start_date');
$promo_text_end_date = $_productdata->getData('promo_text_end_date');
$todays_datefor_promo_text = date('Y-m-d h:i:s');
if($promo_text !='')
if($todays_datefor_promo_text >= "$promo_text_start_date 00:00:00" && $todays_datefor_promo_text <= "$promo_text_end_date 11:59:59")
echo "<p class='bogotextcolor'>$promo_text</p>";
Note: Avoid to use object manager directly and avoid to load product that will impact your page speed.
answered Apr 24 at 16:34
Sohel RanaSohel Rana
23.6k34461
23.6k34461
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
add a comment |
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
Thank you Sohel Rana. So I guess i will look up the difference between $objectManager->create and $objectManager->get
– Jayreis
Apr 24 at 16:45
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%2f272322%2fmagento2-showing-a-custom-attribute-on-category-listing-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
You can use by js because this is highly cached page.
– Sohel Rana
Apr 24 at 16:03
I am not sure what use by js means?
– Jayreis
Apr 24 at 16:07
javascript = js
– Sohel Rana
Apr 24 at 16:10