app/template/cosme41/Block/schema_product_review.twig line 1

Open in your IDE?
  1. {% if Product is defined and Product.id is not null %}
  2. <script type="application/ld+json">
  3. {
  4.   "@context": "https://schema.org/",
  5.   "@type": "Product",
  6.   "name": "{{ Product.name | escape('js') }}",
  7.   "image": [
  8.     {% for ProductImage in Product.ProductImage %}
  9.       "{{ app.request.schemeAndHttpHost ~ asset(ProductImage.file_name, 'save_image') | escape('js') }}"{% if not loop.last %},{% endif %}
  10.     {% endfor %}
  11.   ],
  12.   "description": "{{ Product.description_detail | striptags | slice(0, 150) | escape('js') }}",
  13.   "sku": "{{ Product.code | default(Product.id) | escape('js') }}",
  14.   "offers": {
  15.     "@type": "Offer",
  16.     "url": "{{ url('product_detail', {id: Product.id}) }}",
  17.     "priceCurrency": "JPY",
  18.     "price": "{{ Product.price02_inc_tax_min }}",
  19.     "availability": "{% if Product.stock_find %}https://schema.org/InStock{% else %}https://schema.org/OutOfStock{% endif %}"
  20.   }
  21.   {# --- レビュー情報がある場合のみ、aggregateRating と review を出力 --- #}
  22.   {% if ProductReviews is defined and ProductReviews|length > 0 %}
  23.   ,"aggregateRating": {
  24.     "@type": "AggregateRating",
  25.     "ratingValue": "{{ ProductReviewAvg | number_format(1) }}",
  26.     "bestRating": "5",
  27.     "worstRating": "1",
  28.     "reviewCount": "{{ ProductReviewCount }}"
  29.   },
  30.   "review": [
  31.     {% for ProductReview in ProductReviews %}
  32.     {
  33.       "@type": "Review",
  34.       "author": {
  35.         "@type": "Person",
  36.         "name": "{{ ProductReview.reviewer_name | escape('js') }}"
  37.       },
  38.       "datePublished": "{{ ProductReview.create_date|date('Y-m-d') }}",
  39.       "reviewRating": {
  40.         "@type": "Rating",
  41.         "ratingValue": "{{ ProductReview.recommend_level }}",
  42.         "bestRating": "5",
  43.         "worstRating": "1"
  44.       },
  45.       "name": "{{ ProductReview.title | escape('js') }}",
  46.       "reviewBody": "{{ ProductReview.comment | striptags | escape('js') }}"
  47.     }{% if not loop.last %},{% endif %}
  48.     {% endfor %}
  49.   ]
  50.   {% endif %}
  51. }
  52. </script>
  53. {% endif %}