breadcrumbs "ultima" categoria

PHOTO EMBED

Wed Jan 22 2025 07:22:21 GMT+0000 (Coordinated Universal Time)

Saved by @StefanoGi

{% if request.path[1] == 'product' and request.path[2] > '' %}
				    {% set ky = product.categoryUID|keys %}

				    {% set keyToPrint = '' %}
				    {% set countChildren = 0 %}
				    {% set countChildrenOld = 0 %}
				    {% for key,id in product.categoryUID %}
			            {% set countChildrenOld = countChildren %}
				        {% set cat = getCategory(id) %}
				        {% if cat.parentUID > 0 %}
				            {% set countChildren = countChildren + 1 %}
				            {% set c1 = getCategory(cat.parentUID) %}
                            {% if c1.parentUID > 0 %}
    				            {% set countChildren = countChildren + 1 %}
    				            {% set c2 = getCategory(c1.parentUID) %}
    	                        {% if c2.parentUID > 0 %}
        				            {% set countChildren = countChildren + 1 %}
        				            {% set c3 = getCategory(c2.parentUID) %}
        	                        {% if c3.parentUID > 0 %}
            				            {% set countChildren = countChildren + 1 %}
            				            {% set c4 = getCategory(c3.parentUID) %}
            				            {% if c4.parentUID > 0 %}
                				            {% set countChildren = countChildren + 1 %}
                				        {% endif %}
            				        {% endif %}
        				        {% endif %}
    				        {% endif %}
				        {% endif %}
				        {% if countChildren > countChildrenOld %}
				            {#% set countChildren = 0 %#}
				            {% set keyToPrint = id %}
				        {% endif %}
				    {% endfor %}
				    {% if countChildren == 0 and countChildrenOld == 0 %}
				        {% set keyToPrint = product.categoryUID[ky|last] %}
				    {% endif %}
				    
				    {#
                    {% set last_key = ky|last %}
					{% set category_id = product.categoryUID[last_key] %}
					{% set js_cat_path = '' %}
					
					{% set list = getCategoryList(category_id) %}
					#}
					
					{% set list = getCategoryList(keyToPrint) %}
					{% for k,category in list %}
						{% if category.name != '' and not category.disabled %}
							<li  itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
							    <a href="{% if canonical %}{{getSpokenCategoryUrl(category.uid,category.slug)}}{%else%}{{getCategoryURL(category.uid)}}{% endif %}" itemprop="item"> {{ category.name }} </a>
							    <meta itemprop="position" content="{{ (k+3) }}" />
								<meta itemprop="name" content="{{ category.name | escape('html') }}" />
								{% set js_cat_path = js_cat_path ~ ' | ' ~ category.name %}
							</li>
						{% endif %}
					{% endfor %}
					<li  itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
						<a href="{% if canonical %}{{ getSpokenProductUrl(request.path[2],product.slug)}}{%else%}/product/{{request.path[2] }}{% if request.path[3] != ''%}/{{request.path[3] }}{% endif %}{% endif %}" itemprop="item">
							<meta itemprop="name" content="{{ product.title | escape('html')}}" />{{ product.title }}
							<meta itemprop="position" content="{{ k + 4 }}" />
						</a>
					</li>
				{% endif %}
content_copyCOPY