Jump to content

How to add manufacturer (link) to breadcrumb?


Recommended Posts

  • 2 years later...

well, two years late, but it can still help to someone:-)

 

you have to create an override to the productcontroller and put this code there:

protected function assignCategory() {
    parent::assignCategory();

    $navigation_pipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');

    $manufacturer_breadcrumb = '<a href="'.$this->context->link->getManufacturerLink($this->product->id_manufacturer).'">'.Manufacturer::getNameById($this->product->id_manufacturer).'</a><span class="navigation-pipe">'.$navigation_pipe.'</span>';

    // Assign category to the template
    if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) {
        $path = Tools::getPath($this->category->id, $manufacturer_breadcrumb.$this->product->name, true);
    } elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop)) {
        $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id);
        if (Validate::isLoadedObject($this->category) && $this->category->active && $this->category->isAssociatedToShop()) {
            $path = Tools::getPath((int)$this->product->id_category_default, $manufacturer_breadcrumb.$this->product->name);
        }
    }
    if (!isset($path) || !$path) {
        $path = Tools::getPath((int)$this->context->shop->id_category, $manufacturer_breadcrumb.$this->product->name);
    }

    if (Validate::isLoadedObject($this->category)) {
        $this->context->smarty->assign(array(
            'path' => $path
        ));
    }
}
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Hello gergoo

 

I'm newbie in prestashop and didn't understand exactly how I will create. Could you please explain a bit detailed.

 

Thx

controllers/front/productcontroller.php

you should search this words protected function assignCategory() {

then do like that

  • Like 2
Link to comment
Share on other sites

×
×
  • Create New...