Breadcrumb issue

QuintenTeunissenQuintenTeunissen Posts: 2Member

Hi,

We’re having some issues with our breadcrumbs on our store. The product page won’t show the following steps in the breadcrumb.

Home › Brand(Apple) › iPhone(product model) › iPhone 7 Product

Example above is how it should work. But we can’t get the product model visible. Any ideas how we can show every step regardless how the user enters the product page?

Live store: https://www.ionstore.nl/copy-of-iphone-7-zwart-32gb-a-grade.html

Thanks!

3 comments

  • MilesbdMilesbd Posts: 17Moderator, Lightspeed Staff moderator

    Hi, and thanks for the question!

    The breadcrumbs are meant to be generated as user moves through the site, so that the user can revisit previous pages.

    In your instance, it seems that you want to define the "breadcrumb" area to show a sort of navigation path that is pre-defined.

    Would you be able to post a sample of the code that you are trying to use to generate this navigational breadcrumb?

    Looking forward to helping with your code!

  • QuintenTeunissenQuintenTeunissen Posts: 2Member

    Hi Miles,


    This is the code:


    <div class="breadcrumbs">

     

           <a href="{{ '' | url }}" title="{{ 'Home' | t }}">{{ 'Home' | t }}</a>

           <i class="nc-icon-mini arrows-1_small-triangle-right"></i><a href="{{ product.brand.url | url }}">{{ product.brand.title }}</a>

           <i class="nc-icon-mini arrows-1_small-triangle-right"></i><a href="{{ product.categories[0].url | url }}">{{ product.categories[0].title }}</a>

           <i class="nc-icon-mini arrows-1_small-triangle-right"></i><a class="last" href="{{ product.url | url }}">{{ product.title}}</a>

     

    </div>

  • MilesbdMilesbd Posts: 17Moderator, Lightspeed Staff moderator

    Hi @QuintenTeunissen !

    Thanks for the sample code.

    What it looks like you would need to implement is a loop through the product.categories variable, and only output specify the first index.

    Specifying the position in the array in this instance is not working as the product.categories variable is not an explicit array, but rather an object. As this is the case, to access the title of the category, you would need to iterate over the object, in loop form.


    Using your code above, you could use something along the lines of:

    {% for category in product.categories %}

    {% if loop.first %}

    <i class="nc-icon-mini arrows-1_small-triangle-right"></i><a href="{{ category.url | url }}">{{ category.title }}</a>

    {% endif %}

    {% endfor %}


    This should give you the first category in the product.categories object.


    Happy coding!

Sign In or Register to comment.