I cant seem to get Category name while i can Get Id and URL am i doing something wrong?
Layout (catalog_product_view.xml)
<block class="Magento\Catalog\Block\Product\View" name="product.category" template="productCategory.phtml"/>
Template
<?php
$_product = $block->getProduct();
$categoryCollection = $_product->getCategoryCollection();
foreach ($categoryCollection as $value) {
echo $value->getUrl(); // This returns correct Urls
echo $value->getId(); //This return correct Ids
echo $value->getName(); // This returns Null
}
?>
EDIT
Have tried and not showing null
$value->getData()
$value->getPath()
$value->getParentCategory()->getName()
I'm finding this very confusing, as how i can return almost anything except name
Im doing this in magento 2.