custom/plugins/fourtwosixAttributeBadges/src/Resources/views/storefront/component/product/card/box-standard.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/box-standard.html.twig' %}
  2. {% block component_product_box_info %}
  3.     <div class="d-flex fourtwosix-badges">
  4.         {% set badgesMediaIds = [] %}
  5.         {% set propertiesBadge = [] %}
  6.         {% set configDefaultMedia = config('fourtwosixAttributeBadges.config.defaultMedia') %}
  7.         {# checks whether the property group has a customField attribute_badge #}
  8.         {% if product.sortedProperties != null %}
  9.             {% for x in product.sortedProperties|filter(x => x.translated.customFields.attribute_badges == true) -%}
  10.                 {% set propertiesBadge = propertiesBadge|merge(x.options.elements) %}
  11.             {% endfor %}
  12.             {% if propertiesBadge %}
  13.                 {% for badge in propertiesBadge %}
  14.                     {% if badge.mediaId != null %}
  15.                         {% set badgesMediaIds = badgesMediaIds|merge([badge.mediaId]) %}
  16.                     {% else %}
  17.                         {% set badgesMediaIds = badgesMediaIds|merge([configDefaultMedia]) %}
  18.                     {% endif %}
  19.                 {% endfor %}
  20.                 {% set mediaCollection = searchMedia(badgesMediaIds, context.context) %}
  21.                 {% for badge in propertiesBadge|sort((a, b) => a.position <=> b.position)|slice(0,8) %}
  22.                     {% if badge.mediaId != null %}
  23.                         {% set badgeMedia = mediaCollection.get(badge.mediaId) %}
  24.                         {% sw_thumbnails 'product-detail-badge-thumbnails' with {
  25.                             media: badgeMedia,
  26.                             attributes: {
  27.                                 'class': 'img-fluid badgeImgListing',
  28.                                 'data-toggle' : 'tooltip',
  29.                                 'title': badge.translated.name
  30.                             }
  31.                         } %}
  32.                     {% else %}
  33.                         {% set badgeMedia = mediaCollection.get(configDefaultMedia) %}
  34.                         {% sw_thumbnails 'product-detail-badge-thumbnails' with {
  35.                             media: badgeMedia,
  36.                             attributes: {
  37.                                 'class': 'img-fluid badgeImgListing',
  38.                                 'data-toggle' : 'tooltip',
  39.                                 'title': badge.translated.name
  40.                             }
  41.                         } %}
  42.                     {% endif %}
  43.                 {% endfor %}
  44.             {% endif %}
  45.         {% endif %}
  46.     </div>
  47.     {{parent()}}
  48. {% endblock %}