Files
kupshop/web/common/templates/block.schema.tpl
2025-08-02 16:30:27 +02:00

268 lines
9.8 KiB
Smarty

{block "schema-product"}
{if $body.product.title and !$body.product->isold()}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "{$body.product.title}",
"productID": "{$body.product.id}",
{if $body.product.image or $body.product.photos}
"image": [
{if $body.product.image}"{get_photo photo=$body.product.image size=0 absolute=1}"{/if}{if $body.product.photos},{/if}
{foreach $body.product.photos as $photo}
"{get_photo photo=$photo size=0 absolute=1}"{if !$photo@last},{/if}
{/foreach}
],
{/if}
{if $body.product.descr}
"description": "{$body.product.descr|strip_tags|escape|strip}",
{elseif $body.product.longDescr}
"description": "{$body.product.longDescr|strip_tags|escape|strip}",
{/if}
{block "product-price"}
{get_delivery_dates product=$body.product assign='deliveries'}
{$time_days_min = 0}
{$time_days_max = 0}
{foreach $deliveries.list as $delivery}
{if $delivery.time_days|default:0 <= $time_days_min}
{$time_days_min = $delivery.time_days|default:0}
{elseif $delivery.time_days|default:0 > $time_days_max}
{$time_days_max = $delivery.time_days|default:0}
{/if}
{/foreach}
{if !$body.product.variations.variations}
"offers": {
"@type": "Offer",
"priceCurrency": "{$ctrl.currency|default:'CZK'}",
"price": "{$body.product.productPrice.value_with_vat->printFloatValue(-2)}",
"priceValidUntil" : "{"+31 days"|date_format:"%Y-%m-%d"}",
{block "availability-no-variations"}
"availability": "http://schema.org/{if $body.product.deliveryTime == 0 || $body.product.deliveryTime == $cfg['Modules']['products_suppliers']['delivery_time']}InStock{elseif $body.product.deliveryTime == '-1'}OutOfStock{else}PreOrder{/if}",
{/block}
"shippingDetails": {
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "{$deliveries.min.deliveryPrice|format_price:"printcurrency=no"}",
"currency": "{$ctrl.currency|default:'CZK'}"
},
"shippingDestination": {
"@type": "DefinedRegion",
"addressCountry": "{$ctrl.active_country|default:'CZ'}"
},
"deliveryTime": {
"@type": "ShippingDeliveryTime",
"handlingTime": {
"@type": "QuantitativeValue",
"minValue": 0,
"maxValue": 1,
"unitCode": "DAY"
},
"transitTime": {
"@type": "QuantitativeValue",
"minValue": "{$time_days_min}",
"maxValue": "{$time_days_max}",
"unitCode": "DAY"
}
}
}
}{else}
"offers": {
"@type": "AggregateOffer",
"priceCurrency": "{$ctrl.currency|default:'CZK'}",
"offerCount": {$body.product.variations.variations|count},
"lowPrice": "{$body.product.productPrice.value_with_vat->printFloatValue(-2)}",
"highPrice": "{$body.product.priceMax.value_with_vat->printFloatValue(-2)}",
"priceValidUntil" : "{"+31 days"|date_format:"%Y-%m-%d"}",
"offers": [
{foreach $body.product.variations.variations as $variation}
{
{$delivery_time_index = $variation.delivery_time_index}
{if $variation.delivery_time_raw > 0}
{$delivery_time_index = $variation.delivery_time_raw}
{/if}
{if $body.product.campaign_codes['O'] and $variation.delivery_time_raw <= 0}
{$delivery_time_index = 0}
{/if}
"@type": "Offer",
"sku": "{$body.product.id}_{$variation.id}",
"price": "{$variation.price.value_with_vat->printFloatValue(-2)}",
{block "availability-variations"}
"availability": "http://schema.org/{if $delivery_time_index == 0 || $delivery_time_index == $cfg['Modules']['products_suppliers']['delivery_time']}InStock{elseif $delivery_time_index < 0}OutOfStock{else}PreOrder{/if}",
{/block}
"shippingDetails": {
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "{$deliveries.min.deliveryPrice|format_price:"printcurrency=no"}",
"currency": "{$ctrl.currency|default:'CZK'}"
},
"shippingDestination": {
"@type": "DefinedRegion",
"addressCountry": "{$ctrl.active_country|default:'CZ'}"
},
"deliveryTime": {
"@type": "ShippingDeliveryTime",
"handlingTime": {
"@type": "QuantitativeValue",
"minValue": 0,
"maxValue": 1,
"unitCode": "DAY"
},
"transitTime": {
"@type": "QuantitativeValue",
"minValue": "{$time_days_min}",
"maxValue": "{$time_days_max}",
"unitCode": "DAY"
}
}
}
{if $variation.ean}
,"gtin": "{$variation.ean}"
{/if}
}{if !$variation@last},{/if}
{/foreach}
]
}
{/if}{/block}{if $body.product.producer.id},
"brand": {
"@type": "Brand",
"name": "{$body.product.producer.title|escape:"html"}"{if $body.product.producer.image},
"logo": "{get_photo photo=$body.product.producer.image size=7 absolute=1}"{/if}
}{/if}{if $cfg.Modules.reviews}{get_ratings assign=ratings id_product=$body.product.id skip_empty=true}{if $ratings.rating_count > 0},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{$ratings.rating|round:1}",
"ratingCount": "{$ratings.rating_count}"
},
"review": [
{foreach $ratings.reviews as $rating}
{if $rating.user_name || $rating.name}
{if !$rating@first},{/if}
{
"@type": "Review",
"author": {
"@type": "Person",
"name": "{$rating.name|default:$rating.user_name}"
},
"datePublished": "{$rating.date|date_format:"%Y-%m-%d"}",
"description": "{$rating.summary|strip_tags|escape|strip}",
"reviewRating": {
"@type": "Rating",
"ratingValue": "{$rating.rating|round}"
}
}
{/if}
{/foreach}
]
{/if}{/if}
{if $body.product.ean},
"gtin13":"{$body.product.ean}"
{elseif $body.product.variations.variations}
{foreach $body.product.variations.variations as $variation}
{if $variation@iteration == 1},
"gtin13":"{$variation.ean}"
{break}
{/if}
{/foreach}
{/if}
{if $body.product.id},
"sku":"{$body.product.id}"
{/if}
}
</script>
{/if}
{/block}
{if $breadcrumbs and $breadcrumbs|count > 1}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{foreach $breadcrumbs as $item}
{if !$item@first}
{$comma}{
"@type": "ListItem",
"position": {$item@index},
"item": {
"@id": "{if $item.link}{substr($cfg.Addr.full, 0, -1)}{$item.link}{else}{$ctrl.currUrl.Abs}{/if}",
"name": "{if $body.producer.id and $item@iteration == 2}{$body.producer.name}{else}{$item.text}{/if}"
}
}
{assign var="comma" value=", "}
{/if}
{/foreach}
]}
</script>
{/if}
{if $body.article}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "NewsArticle",
"headline" : "{$body.article.title}",
"author" : {
"@type" : "Person",
{if $body.article.authors}
{foreach $body.article.authors as $author}
{if $author.active == "Y"}
"name" : "{$author.name} {$author.surname}"
{break}
{elseif $author@last}
"name" : "{$body.article.data['author']|default:$dbcfg.shop_firm_name}"
{/if}
{/foreach}
{else}
"name" : "{$body.article.data['author']|default:$dbcfg.shop_firm_name}"
{/if}
},
{if $body.article.image}
"image":[
"{get_photo photo=$body.article.image size=4 absolute=1}"
],
{/if}
{if $body.article.date}
"datePublished" : "{$body.article.date|date_format:"%Y-%m-%d"}",
{/if}
"url" : "{$ctrl.currUrl.Abs}",
{if $body.article.lead}
"description": "{$body.article.lead}",
{/if}
"publisher": {
"@type": "Organization",
"name": "{$dbcfg.shop_firm_name}",
"logo": {
"@type": "ImageObject",
"url": "{static_url url="/templates/images/logo.png" absolute=1}"
}
}
}
</script>
{/if}
{ifmodule REVIEWS}
{if $body.category.id || $body.page.code == 'system-home'}
{* Zobrazeni hodnoceni shopu pouze kdyz je vic jak 5 hodnoceni a prumer 4+ hvezdicek *}
{get_stats assign='ratingValue' type='average_rating'}
{get_stats assign='reviewCount' type='reviews_count'}
{if ($ratingValue && $ratingValue >= 4)
&& ($reviewCount && $reviewCount >= 5)}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Product",
"name" : "{$dbcfg.shop_firm_name}",
"aggregateRating" : {
"@type" : "AggregateRating",
"ratingValue" : {$ratingValue|round:1},
"reviewCount" : {$reviewCount}
}
}
</script>
{/if}
{/if}
{/ifmodule}