0

I need to show category name on product detail page just before product name.

Currently product name display as page title but i need to display additionally product name with class new class name. category name will also display with class name just before product name.

How i can complete the task.

4
  • What is class name?
    – LucScu
    May 4, 2016 at 7:38
  • class name which is append to html. May 4, 2016 at 7:41
  • This is the default html <h1 class="page-title"><span class="base" data-ui-id="page-title-wrapper" itemprop="name">[product-name]</span></h1>. How your html have to be?
    – LucScu
    May 4, 2016 at 7:49
  • i need to show category name. how can it ? May 4, 2016 at 8:34

1 Answer 1

0

You can use below code to display category name in product detail page.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currentcategory = $objectManager->get('Magento\Framework\Registry')->registry('current_category');
echo $currentcategory->getName();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.