vendor/joppedc/sylius-better-seo-plugin/src/Resources/views/_structured_data.html.twig line 1

Open in your IDE?
  1. {% set product = settings.product %}
  2. {% set reviews = product.acceptedReviews %}
  3. {% if reviews is not empty %}
  4.   {% set minReview = reviews | first.rating %}
  5.   {% set maxReview = minReview %}
  6.   {% for review in reviews %}
  7.     {% if(review.rating > maxReview) %}
  8.       {% set maxReview = review.rating %}
  9.     {% elseif(review.rating < minReview) %}
  10.       {% set minReview = review.rating %}
  11.     {% endif %}
  12.   {% endfor %}
  13. {% endif %}
  14. {% set minPrice = product.variants.first.channelPricingForChannel(sylius.channel).price / 100 %}
  15. {% set maxPrice = minPrice %}
  16. {% for variant in product.variants %}
  17.   {% set variantPrice = variant.channelPricingForChannel(sylius.channel).price / 100 %}
  18.   {% if(variantPrice > maxPrice) %}
  19.     {% set maxPrice = variantPrice %}
  20.   {% elseif(variantPrice < minPrice) %}
  21.     {% set minPrice = variantPrice %}
  22.   {% endif %}
  23. {% endfor %}
  24. {% if product.images.first %}
  25.   {% set source_image_path = product.images.first.path %}
  26.   {% set original_image_path = source_image_path|imagine_filter('sylius_shop_product_original') %}
  27. {% endif %}
  28. <script type="application/ld+json">
  29.   {
  30.     "@context": "http://schema.org",
  31.     "@type": "Product",
  32.     {% if reviews is not empty %}
  33.       "aggregateRating": {
  34.         "@type": "AggregateRating",
  35.         "ratingValue": "{{ product.averageRating }}",
  36.         "reviewCount": "{{ reviews | length }}"
  37.       },
  38.     {% endif %}
  39.     "description": "{{ product.shortDescription }}",
  40.     "name": "{{ product.name }}",
  41.     {% if product.images.first %}
  42.       "image": "{{ original_image_path }}",
  43.     {% endif %}
  44.     {% if reviews is not empty %}
  45.       "review": [
  46.         {% for review in reviews %}
  47.           {
  48.             "@type": "Review",
  49.             "author": "{{ review.author.firstName }}",
  50.             "datePublished": "{{ review.createdAt | date('Y-m-d') }}",
  51.             "description": "{{ review.comment }}",
  52.             "name": "{{ review.title }}",
  53.             "reviewRating": {
  54.               "@type": "Rating",
  55.               "ratingValue": "{{ review.rating }}"
  56.             }
  57.           }{% if not loop.last %},{% endif %}
  58.         {% endfor %}
  59.       ],
  60.     {% endif %}
  61.     "offers": {
  62.       "@type": "AggregateOffer",
  63.       "highPrice": "{{ maxPrice }}",
  64.       "lowPrice": "{{ minPrice }}",
  65.       "offerCount": "{{ product.variants | length }}",
  66.       "priceCurrency": "{{ sylius.channel.baseCurrency.code }}"
  67.     },
  68.     "url": "{{ app.request.uri }}"
  69.   }
  70. </script>