custom/plugins/theme/src/Resources/views/storefront/page/product-detail/meta.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
  2. {% block layout_head_meta_tags_opengraph %}
  3.     {{ parent() }}
  4.     {% set productReviewCount = page.product.extensions.rating.totalReviews %}
  5.     {% if productReviewCount > 0 %}
  6.         {% set productAvgRating = page.product.extensions.rating.rating|round(2, "common")  %}
  7.     {% endif %}
  8.     {% set price = page.product.price.elements | first %}
  9.     {% set imageArray = [] %}
  10.     {% for image in page.product.media.elements %}
  11.         {% set imageArray = imageArray| merge([image.media.url]) %}
  12.     {% endfor %}
  13.     <script type="application/ld+json">
  14.         [{
  15.             "@context": "https://schema.org/",
  16.             "@type": "Product",
  17.             "name": "{{ page.product.translated.name }}",
  18.             "description": "{{ metaDescription }}",
  19.             "sku": "{{ page.product.productNumber }}",
  20.             "mpn": "{{ page.product.productNumber }}",
  21.             "brand": {
  22.                 "@type": "Brand",
  23.                 "name": "{{ page.product.manufacturer.name }}"
  24.             },
  25.             "offers": [
  26.                 {
  27.                     "@type": "Offer",
  28.                     "availability": "https://schema.org/LimitedAvailability",
  29.                     "itemCondition": "https://schema.org/NewCondition",
  30.                     "price": "{{ price.gross }}",
  31.                     "priceCurrency": "EUR",
  32.                     "priceValidUntil": "{{ 'now'|date('d-m-Y') }}",
  33.                     "url": "{{  page.extensions.dreiscSeoInstallmentRichSnippetData.ldJson[0].offers[0].url }}",
  34.                     "shippingDetails": {
  35.                       "@type": "OfferShippingDetails",
  36.                       "shippingRate": {
  37.                           "@type": "MonetaryAmount",
  38.                           "value": "9.95",
  39.                           "currency": "EUR"
  40.                       },
  41.                       "shippingDestination": [
  42.                           {
  43.                             "@type": "DefinedRegion",
  44.                             "addressCountry": "DE"
  45.                           }
  46.                       ],
  47.                         "deliveryTime": {
  48.                             "@type": "ShippingDeliveryTime",
  49.                             "handlingTime": {
  50.                               "@type": "QuantitativeValue",
  51.                               "minValue": 0,
  52.                               "maxValue": 1,
  53.                               "unitCode": "DAY"
  54.                             },
  55.                             "transitTime": {
  56.                               "@type": "QuantitativeValue",
  57.                               "minValue": 1,
  58.                               "maxValue": 2,
  59.                               "unitCode": "DAY"
  60.                             }
  61.                         }
  62.                     }
  63.                 }
  64.             ],
  65.          {% if productAvgRating > 0 and productReviewCount > 0 %}
  66.             {% for review in (page.product.extensions.reviews.all()|slice(0,1)) %}
  67.                 "review": {
  68.                     "@type": "Review",
  69.                     "reviewRating": {
  70.                       "@type": "Rating",
  71.                       "ratingValue": "{{ review.stars }}",
  72.                       "bestRating": 5
  73.                     },
  74.                     "author": {
  75.                       "@type": "Person",
  76.                       "name": "{% if review.reviewer %} {{ review.reviewer }} {% else %}anonym{% endif %}"
  77.                     }
  78.                 },
  79.             {% endfor %}
  80.             "aggregateRating": {
  81.                 "@type": "AggregateRating",
  82.                 "ratingValue": "{{ productAvgRating }}",
  83.                 "reviewCount": "{{ productReviewCount }}"
  84.             },
  85.           {% endif %}
  86.           "image": [
  87.             "{{ imageArray[0] }}",
  88.             "{{ imageArray[1] }}",
  89.             "{{ imageArray[2] }}"
  90.           ]
  91.       },
  92.       {
  93.         "@context": "https://schema.org",
  94.         "@type": "BreadcrumbList",
  95.         "itemListElement": [
  96.             {
  97.                 "@type": "ListItem",
  98.                 "item": "https://doncarne.de/{{ page.product.seoCategory.translated.externalLink }}",
  99.                 "name": "{{ page.product.seoCategory.translated.name }}",
  100.                 "position": 1
  101.             }
  102.         ]
  103.       }]
  104.     </script>
  105. {% endblock %}
  106. {% block layout_head_title_inner %}
  107.     {% if page.metaInformation.metaTitle %}{{ page.metaInformation.metaTitle }}{% else %}{{ page.product.translated.name }}{% if page.product.variation %} - {% for variation in page.product.variation %}{{ variation.group }}: {{ variation.option }}{% if page.product.variation|last != variation %}{{ " | " }}{% endif %}{% endfor %}{% endif %}{% endif %}
  108. {% endblock %}
  109. {% block layout_head_canonical %}
  110.     {% set canonicalUrl = page.product.id %}
  111.     {% if page.product.canonicalProductId %}
  112.         {% set canonicalUrl = page.product.canonicalProductId %}
  113.     {% endif %}
  114.     <link rel="canonical" href="{{ seoUrl('frontend.detail.page', { productId: canonicalUrl }) }}" />
  115. {% endblock %}