I am trying to get breadcrumb path in my controller by using this helper

public function __construct(\Magento\Catalog\Helper\Data $catalogData, ) {
$this->catalogData = $catalogData;
$path = $this->catalogData->getBreadcrumbPath();

When I print $path it's giving me an empty array. But when I get this helper function in any product phtml file like this

$helper = $this->helper('\Magento\Catalog\Helper\Data');
$values = $helper->getBreadcrumbPath();

it's giving me the full path in phtml. How can I access this function in my controller as well?



Your Answer

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

Browse other questions tagged or ask your own question.