Question

How can I get the product category's URL Key?

I can get the category name by $category->getName() but it does not work if I use this $category->getURLKey(),

$categories = $_product->getCategoryCollection()
    ->addAttributeToSelect('name');

foreach($categories as $category) {
    $productCategoryName = $category->getName();
    var_dump($category->getURLKey());
}

Return null

Any ideas?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top