0

Ok, this is the full error actually:

TypeError: Return value of Magento\Catalog\ViewModel\Product\Breadcrumbs::getProductName() must be of the type string, null returned in /var/www/html/vendor/magento/module-catalog/ViewModel/Product/Breadcrumbs.php:101 

When I open index page it shows this error and long stack trace of 70 files.

I inspected the source magento files and its this function, which seams alright. So I am confused what is doing it.

public function getProductName(): string
    {
        return $this->catalogData->getProduct() !== null
            ? $this->catalogData->getProduct()->getName()
            : '';
    }

I am using latest magento 2.4.1 I tried disablin all 3-rd party modules. Changes nothing.

5
  • Looks like you have quotes in product name. github.com/magento/magento2/issues/15631
    – Anton
    Dec 14, 2020 at 20:19
  • Yeah, you reminded me of that bug. How did it end up in 2.4.1 . I am guessing one of my modules contains override code from earlier versions. Dec 14, 2020 at 23:10
  • I resolved just resave product with a name which throw exception.
    – Anton
    Dec 18, 2020 at 9:19
  • But what about mass import? Dec 18, 2020 at 12:32
  • I got the same error. Did anyone solve it ?
    – Amit Singh
    Mar 25, 2021 at 13:55

2 Answers 2

1

solution: login to admin goto catalog->product search for the product where any product has no product name and URL key.

just update the product name and URL key.

this was fixed for me.

0

OK, so for anyone that has this problem. It is an open ticket.

As Anton said double quotes are causing this problem. So the solution is to remove double quotes from title of products.

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.