Jump to content

Solved | Override problem that causes breadcrumb to repeat prestashop 1.7.8.3


Toulousain

Recommended Posts

Hello,

The breadcrumb is displayed twice in a row when I set an override of the getBreadcrumbLinks() function in the ProductController.php file.

image.thumb.png.7d37d09949766cc7707bc13e34dda1c1.png

 

If I disable the getBreadcrumbLinks() function of the override the breadcrumb display is correct.

image.thumb.png.fa56754d77a125cc246d5d842896d947.png

 

I specify that I did not modify the getBreadcrumbLinks() function placed in the override it is the native function of prestashop.

Do you know what can cause this problem and how to correct it?

Thanks a lot

Here is the function that causes the problem 

     public function getBreadcrumbLinks()
    {
        $breadcrumb = parent::getBreadcrumbLinks();

        $categoryDefault = new Category($this->product->id_category_default, $this->context->language->id);

        foreach ($categoryDefault->getAllParents() as $category) {
            if ($category->id_parent != 0 && !$category->is_root_category && $category->active) {
                $breadcrumb['links'][] = [
                    'title' => $category->name,
                    'url' => $this->context->link->getCategoryLink($category),
                ];
            }
        }

        if ($categoryDefault->id_parent != 0 && !$categoryDefault->is_root_category && $categoryDefault->active) {
            $breadcrumb['links'][] = [
                'title' => $categoryDefault->name,
                'url' => $this->context->link->getCategoryLink($categoryDefault),
            ];
        }

        $breadcrumb['links'][] = [
            'title' => $this->product->name,
			//'title' => $this->getProductPageTitle(),
            'url' => $this->context->link->getProductLink($this->product, null, null, null, null, null, (int) $this->getIdProductAttributeByRequest()),
        ];

        return $breadcrumb;
    }

 

Edited by Toulousain
solved (see edit history)
Link to comment
Share on other sites

  • Toulousain changed the title to Solved | Override problem that causes breadcrumb to repeat prestashop 1.7.8.3
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...