forked from PrestaShop/hummingbird
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-jsonld.tpl
More file actions
88 lines (82 loc) · 3.03 KB
/
product-jsonld.tpl
File metadata and controls
88 lines (82 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*}
{assign var=hasAggregateRating value=false}
{if !empty($product.productComments.averageRating) && !empty($product.productComments.nbComments)}
{assign var=hasAggregateRating value=true}
{assign var=ratingValue value=$product.productComments.averageRating}
{assign var=ratingReviewCount value=$product.productComments.nbComments}
{/if}
{if !empty($ratings.avg) && !empty($nbComments)}
{assign var=hasAggregateRating value=true}
{assign var=ratingValue value=$ratings.avg}
{assign var=ratingReviewCount value=$nbComments}
{/if}
{assign var=hasWeight value=false}
{if isset($product.weight) && ($product.weight != 0)}
{assign var=hasWeight value=true}
{/if}
{assign var=hasOffers value=$product.show_price}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{$product.name}",
"description": "{$page.meta.description|regex_replace:"/[\r\n]/" : " "}",
"category": "{$product.category_name}",
{if !empty($product.cover)}"image" :"{$product.cover.bySize.home_default.url}",{/if}
"sku": "{if $product.reference}{$product.reference}{else}{$product.id}{/if}",
"mpn": "{if $product.mpn}{$product.mpn}{elseif $product.reference}{$product.reference}{else}{$product.id}{/if}"
{if $product.ean13},"gtin13": "{$product.ean13}"{/if}
{if $product.upc},"gtin12": "{$product.upc}"{/if}
{if isset($product_manufacturer) && $product_manufacturer->name},
"brand": {
"@type": "Brand",
"name": "{$product_manufacturer->name|escape:'html':'UTF-8'}"
}
{elseif $shop.name},
"brand": {
"@type": "Organization",
"name": "{$shop.name}"
}
{/if}
{if $hasAggregateRating},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{$ratingValue|round:1|escape:'html':'UTF-8'}",
"reviewCount": "{$ratingReviewCount|escape:'html':'UTF-8'}"
}
{/if}
{if $hasWeight},
"weight": {
"@context": "https://schema.org",
"@type": "QuantitativeValue",
"value": "{$product.weight}",
"unitCode": "{$product.weight_unit}"
}
{/if}
{if $hasOffers},
"offers": {
"@type": "Offer",
"priceCurrency": "{$currency.iso_code}",
"price": "{$product.price_amount}",
"url": "{$product.url}",
"priceValidUntil": "{($smarty.now + (int) (60*60*24*15))|date_format:"%Y-%m-%d"}",
{if $product.images|count > 0}
"image": {strip}[
{foreach from=$product.images item=p_img name="p_img_list"}
"{$p_img.large.url}"{if not $smarty.foreach.p_img_list.last},{/if}
{/foreach}
]{/strip},
{/if}
{if !empty($product.show_condition) && !empty($product.condition)}"itemCondition": "{$product.condition.schema_url}",{/if}
"availability": "{$product.seo_availability}",
"seller": {
"@type": "Organization",
"name": "{$shop.name}"
}
}
{/if}
}
</script>