![](/img/trans.png)
[英]How to communicate with Shopify Storefront and add JS snippet to Product Page
[英]How can I add multiple reviews to a product snippet?
我試圖在JSON-LD中創建具有多個評論的產品代碼段。 當我僅包含一個評論時,以下代碼有效。 (請將代碼片段復制粘貼到控制台中的以下URL上以對其進行測試: https : //search.google.com/structured-data/testing-tool )。 但是,對於我來說,尚不清楚如何添加多個評論。 經過一段時間的努力,我自己無法工作,我很難找到一個例子。
假設我有“約翰”的評論,他給產品評分為“ 3.0”,還有另一條“莎拉”評論,給產品評分為“ 5.0”。 我如何在下面的代碼中包含對Sarah的評論?
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "Samsung Galaxy S",
"description": "A great product",
"brand": {
"@type": "Thing",
"name": "Samsung"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.0",
"reviewCount": "103"
},
"offers": {
"@type": "Offer",
"priceCurrency": "EUR",
"price": "18",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock",
"seller": {
"@type": "Organization",
"name": "Samsung"
}
}
,"review": {
"@type": "Review",
"author": "John",
"datePublished": " 7 December 2016",
"description": "I love this product so much",
"name": "Amazing",
"reviewRating": {
"@type": "Rating",
"bestRating": "5",
"ratingValue": "3.0",
"worstRating": "1"
}
}
}
您可以將多個JSON-LD代碼段附加到單個頁面上,因此沒有理由無法從示例中刪除評論數據,並將其移動到獨立代碼段中。 然后為“ Sarah”創建另一個代碼段
這是一些樣板JSON-LD進行審查
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"image": "http://www.example.com/iphone-case.jpg",
"name": "The Catcher in the Rye",
"review": {
"@type": "Review",
"reviewRating": {
"@type": "Rating",
"ratingValue": "4"
},
"name": "iPhone 6 Case Plus",
"author": {
"@type": "Person",
"name": "Linus Torvalds"
},
"datePublished": "2016-04-04",
"reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
"publisher": {
"@type": "Organization",
"name": "iPhone 6 Cases Inc."
}
}
}
</script>
如果您在https://search.google.com/structured-data/testing-tool上使用多個代碼片段測試了此方法,則會看到它將會驗證。
另外,我也可以在網站上進行等效的操作。 我已經刪除了單個評論並修改了您的aggregateRating塊
<script type="application/ld+json"> {
"@context": "http://schema.org/",
"@type": "Product",
"name": "Samsung Galaxy S",
"description": "A great product",
"brand": {
"@type": "Thing",
"name": "Samsung"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4",
"reviewCount": "103",
"worstRating": "1",
"bestRating": "5"
},
"offers": {
"@type": "Offer",
"priceCurrency": "EUR",
"price": "18",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock",
"seller": {
"@type": "Organization",
"name": "Samsung"
}
}
}</script>
祝好運!
您可以將評論指定為數組,
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"image": "http://www.example.com/iphone-case.jpg",
"name": "The Catcher in the Rye",
"review": [
{
"@type": "Review",
"reviewRating": {
"@type": "Rating",
"ratingValue": "4"
},
"name": "iPhone 6 Case Plus",
"author": {
"@type": "Person",
"name": "Linus Torvalds"
},
"datePublished": "2016-04-04",
"reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
"publisher": {
"@type": "Organization",
"name": "iPhone 6 Cases Inc."
}
},
{
"@type": "Review",
"reviewRating": {
"@type": "Rating",
"ratingValue": "4"
},
"name": "iPhone 6 Case Plus+",
"author": {
"@type": "Person",
"name": "Linus Torvalds"
},
"datePublished": "2019-04-04",
"reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
"publisher": {
"@type": "Organization",
"name": "iPhone 6 Cases Inc."
}
}
]
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.