Jump to content

Edit History

Toulousain

Toulousain


solved

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;
    }

 

Toulousain

Toulousain

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;
    }

 

×
×
  • Create New...