show category name in product detail pageHow to display category name in product page?Magento2 : Show category name on product detail pageMagento 2 - Show subcategories (and products) on category pageBannerslider not compatible with Magento 2.1?Uncaught TypeError: Argument 1 passed to […] must be an instance ofShow Upsell Product in product detail pageMagento replace home by categoryMagento 2.2 - Breadcrumbs issueMagento 2.2.3 Order variables in success pageMagento 2, category disappeared on “Catalog > Category” tree, does show everywhere else
Source of the Wildfire?
Do not cross the line!
Motorola 6845 and bitwise graphics
Do Grothendieck universes matter for an algebraic geometer?
How to not get blinded by an attack at dawn
Did galley captains put corks in the mouths of slave rowers to keep them quiet?
Fixed width with p doesn't work
Developers demotivated due to working on same project for more than 2 years
Why weren't the bells paid heed to in S8E5?
Was the dragon prowess intentionally downplayed in S08E04?
Is there any good reason to write "it is easy to see"?
How to describe a building set which is like LEGO without using the "LEGO" word?
"Every hiker climbed a hill", is there one or multiple hills?
Why doesn't Iron Man's action affect this person in Endgame?
Will a coyote attack my dog on a leash while I'm on a hiking trail?
Filter a data-frame and add a new column according to the given condition
Why do the lights go out when someone enters the dining room on this ship?
Can my Serbian girlfriend apply for a UK Standard Visitor visa and stay for the whole 6 months?
Substring join or additional table, which is faster?
Uh oh, the propeller fell off
How to redirect stdout to a file, and stdout+stderr to another one?
complicated arrows in flowcharts
How do I adjust encounters to challenge my lycanthrope players without negating their cool new abilities?
Why are solar panels kept tilted?
show category name in product detail page
How to display category name in product page?Magento2 : Show category name on product detail pageMagento 2 - Show subcategories (and products) on category pageBannerslider not compatible with Magento 2.1?Uncaught TypeError: Argument 1 passed to […] must be an instance ofShow Upsell Product in product detail pageMagento replace home by categoryMagento 2.2 - Breadcrumbs issueMagento 2.2.3 Order variables in success pageMagento 2, category disappeared on “Catalog > Category” tree, does show everywhere else
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to get the name of a category in the addtocart.phtml. I know products could be assigned to more then one category so I am fine with having a loop if need be. Anyway here is my code which i thought would display the name of the category that the product is in/being viewed in.
does anyone know how I should alter this?
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get current category
$category_name = $category->getName();
magento2
add a comment |
I am trying to get the name of a category in the addtocart.phtml. I know products could be assigned to more then one category so I am fine with having a loop if need be. Anyway here is my code which i thought would display the name of the category that the product is in/being viewed in.
does anyone know how I should alter this?
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get current category
$category_name = $category->getName();
magento2
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42
add a comment |
I am trying to get the name of a category in the addtocart.phtml. I know products could be assigned to more then one category so I am fine with having a loop if need be. Anyway here is my code which i thought would display the name of the category that the product is in/being viewed in.
does anyone know how I should alter this?
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get current category
$category_name = $category->getName();
magento2
I am trying to get the name of a category in the addtocart.phtml. I know products could be assigned to more then one category so I am fine with having a loop if need be. Anyway here is my code which i thought would display the name of the category that the product is in/being viewed in.
does anyone know how I should alter this?
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');//get current category
$category_name = $category->getName();
magento2
magento2
asked May 9 at 18:11
JayreisJayreis
322933
322933
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42
add a comment |
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42
add a comment |
2 Answers
2
active
oldest
votes
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product'); /* You will get current product from here */
$categories = $product->getCategoryIds(); /* You will get array of categories id */
foreach($categories as $category)
$catData = $objectManager->create('MagentoCatalogModelCategory')->load($category);
echo $catData->getName();
?>
add a comment |
Using Product Id Get All Category Name Which Assign This Product
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory')->create()->load($product_id);
$categoryIds = $productFactory->getCategoryIds();
foreach($categoryIds as $category)
$id = $category->getId();
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory')->create()->load($id);
$categoryName = $categoryFactory->getName();
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%2f274057%2fshow-category-name-in-product-detail-page%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
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product'); /* You will get current product from here */
$categories = $product->getCategoryIds(); /* You will get array of categories id */
foreach($categories as $category)
$catData = $objectManager->create('MagentoCatalogModelCategory')->load($category);
echo $catData->getName();
?>
add a comment |
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product'); /* You will get current product from here */
$categories = $product->getCategoryIds(); /* You will get array of categories id */
foreach($categories as $category)
$catData = $objectManager->create('MagentoCatalogModelCategory')->load($category);
echo $catData->getName();
?>
add a comment |
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product'); /* You will get current product from here */
$categories = $product->getCategoryIds(); /* You will get array of categories id */
foreach($categories as $category)
$catData = $objectManager->create('MagentoCatalogModelCategory')->load($category);
echo $catData->getName();
?>
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product'); /* You will get current product from here */
$categories = $product->getCategoryIds(); /* You will get array of categories id */
foreach($categories as $category)
$catData = $objectManager->create('MagentoCatalogModelCategory')->load($category);
echo $catData->getName();
?>
answered May 9 at 18:44
Saphal JhaSaphal Jha
907616
907616
add a comment |
add a comment |
Using Product Id Get All Category Name Which Assign This Product
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory')->create()->load($product_id);
$categoryIds = $productFactory->getCategoryIds();
foreach($categoryIds as $category)
$id = $category->getId();
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory')->create()->load($id);
$categoryName = $categoryFactory->getName();
add a comment |
Using Product Id Get All Category Name Which Assign This Product
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory')->create()->load($product_id);
$categoryIds = $productFactory->getCategoryIds();
foreach($categoryIds as $category)
$id = $category->getId();
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory')->create()->load($id);
$categoryName = $categoryFactory->getName();
add a comment |
Using Product Id Get All Category Name Which Assign This Product
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory')->create()->load($product_id);
$categoryIds = $productFactory->getCategoryIds();
foreach($categoryIds as $category)
$id = $category->getId();
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory')->create()->load($id);
$categoryName = $categoryFactory->getName();
Using Product Id Get All Category Name Which Assign This Product
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory')->create()->load($product_id);
$categoryIds = $productFactory->getCategoryIds();
foreach($categoryIds as $category)
$id = $category->getId();
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory')->create()->load($id);
$categoryName = $categoryFactory->getName();
answered May 10 at 5:41
Rk RathodRk Rathod
1,790214
1,790214
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%2f274057%2fshow-category-name-in-product-detail-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
Please check magento.stackexchange.com/questions/202423/…
– BartZalas
May 9 at 21:27
using product id get all category name which assign this product ??
– Rk Rathod
May 10 at 5:32
Possible duplicate of How to display category name in product page?
– Rakesh Donga
May 10 at 5:42