Jump to content

[TUTORIAL] Show product categories instead of breadcrumb - PS 1.7


shacker

Recommended Posts

If your site has many products, it is convenient at the seo level to remove the breadcrumbs from the products since there are products that are referenced in multiple categories and the breadcrumbs are not a faithful reference

Instead, and to favor the internal linking of the categories, it is changed by inserting links to the categories to which the product belongs. They would be displayed similar to how they are shown

The breadcrumb in PrestaShop 1.7 is:

<nav data-depth="{$breadcrumb.count}" class="breadcrumb">

  <ol>

    {block name='breadcrumb'}

      {foreach from=$breadcrumb.links item=path name=breadcrumb}

        {block name='breadcrumb_item'}

          <li>

            {if not $smarty.foreach.breadcrumb.last}

              <a href="{$path.url}"><span>{$path.title}</span></a>

            {else}

              <span>{$path.title}</span>

            {/if}

          </li>

        {/block}

      {/foreach}

    {/block}

  </ol>

</nav>

Replace it with this code

{if isset($breadcrumb.links[1])}

  {if $page_name != 'product'}

  <nav data-depth="{$breadcrumb.count}" class="">

    <ol class="breadcrumb">

      {foreach from=$breadcrumb.links item=path name=breadcrumb}

        {block name='breadcrumb_item'}

          {if $smarty.foreach.breadcrumb.last}

            <li class="breadcrumb-item active">

            {else}

            <li class="breadcrumb-item">

              <a itemprop="item" href="{$path.url}">

              {/if}



              {if $smarty.foreach.breadcrumb.first}

                <i class="icon-Home"></i>

              {else}

                <span itemprop="name">{$path.title}</span>

              {/if}

              {if !$smarty.foreach.breadcrumb.last}

              </a>

            {/if}

          </li>

        {/block}

      {/foreach}

    </ol>

  </nav>

  {else}

 <nav class="">

    <ol class="breadcrumb">

      <li class="breadcrumb-item">

      <a href="{$urls.base_url}" >

      <i class="icon-Home"></i>

      </a>

      </li>

  {foreach from=Product::getProductCategories($product.id) item=cat}

    {if $cat > 2}

      {assign var='current_cat' value=Category::getCategoryInformations(array($cat))}

      <li class="breadcrumb-item">

      <a href="{$link->getCategoryLink({$cat})}" title="{$current_cat[{$cat}]['name']}">

        <span itemprop="name">{$current_cat[{$cat}]['name']}</span>

      </a>

      </li>

    {/if}

  {/foreach}

</ol>

</nav>

  {/if}



  {if $page_name == 'product'}

    <div>

      <p>

        <button class="btn-primary btn-md btn-configurador-back"><i class="icon-Arrow-left"></i>Volver</button>

      </p>

    </div>

  {/if}

{/if}

In this way we will show the categories to which the product belongs.

 

Link

https://catalogo-onlinersi.net/en/content/50-show-product-categories-instead-of-breadcrumb

image.thumb.png.c6380eb8f06ba65b4de01a446bd63e5a.png

Link to comment
Share on other sites

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...