{% if Product is defined and Product.id is not null %}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ Product.name | escape('js') }}",
"image": [
{% for ProductImage in Product.ProductImage %}
"{{ app.request.schemeAndHttpHost ~ asset(ProductImage.file_name, 'save_image') | escape('js') }}"{% if not loop.last %},{% endif %}
{% endfor %}
],
"description": "{{ Product.description_detail | striptags | slice(0, 150) | escape('js') }}",
"sku": "{{ Product.code | default(Product.id) | escape('js') }}",
"offers": {
"@type": "Offer",
"url": "{{ url('product_detail', {id: Product.id}) }}",
"priceCurrency": "JPY",
"price": "{{ Product.price02_inc_tax_min }}",
"availability": "{% if Product.stock_find %}https://schema.org/InStock{% else %}https://schema.org/OutOfStock{% endif %}"
}
{# --- レビュー情報がある場合のみ、aggregateRating と review を出力 --- #}
{% if ProductReviews is defined and ProductReviews|length > 0 %}
,"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{{ ProductReviewAvg | number_format(1) }}",
"bestRating": "5",
"worstRating": "1",
"reviewCount": "{{ ProductReviewCount }}"
},
"review": [
{% for ProductReview in ProductReviews %}
{
"@type": "Review",
"author": {
"@type": "Person",
"name": "{{ ProductReview.reviewer_name | escape('js') }}"
},
"datePublished": "{{ ProductReview.create_date|date('Y-m-d') }}",
"reviewRating": {
"@type": "Rating",
"ratingValue": "{{ ProductReview.recommend_level }}",
"bestRating": "5",
"worstRating": "1"
},
"name": "{{ ProductReview.title | escape('js') }}",
"reviewBody": "{{ ProductReview.comment | striptags | escape('js') }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
]
{% endif %}
}
</script>
{% endif %}