|
|
`
|
|
|
<?php
|
|
|
$priceSchema = $_product->getFinalPrice();
|
|
|
$nameSchema = $_product->getName();
|
|
|
$skuSchema = $_product->getSku();
|
|
|
$eanSchema = $_product->getEan();
|
|
|
$descriptionSchema = $_product->getShortDescription() ? $this->stripTags($_product->getShortDescription()) : $this->stripTags($_product->getDescription());
|
|
|
$urlProdSchema = $_product->getUrl();
|
|
|
$stockSchema = $_product->getIsInStock() ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock';
|
|
|
$imageSchema = '';
|
|
|
|
|
|
foreach ($_product->getMediaGalleryImages() as $image) {
|
|
|
$imageSchema .= '"' . $image->getUrl() . '",';
|
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
|
|
<script type="application/ld+json">
|
|
|
{
|
|
|
"@context": "https://schema.org/",
|
|
|
"@type": "Product",
|
|
|
"name": "<?php echo str_replace('"','',$nameSchema); ?>",
|
|
|
"image": [
|
|
|
<?php echo substr_replace($imageSchema, '', -1); ?>
|
|
|
],
|
|
|
"description": "<?php echo str_replace('"','',$descriptionSchema); ?>",
|
|
|
"sku": "<?php echo $skuSchema;?>",
|
|
|
"offers": {
|
|
|
"@type": "Offer",
|
|
|
"url": "<?php echo $urlProdSchema ?>",
|
|
|
"priceCurrency": "BRL",
|
|
|
"price": "<?php echo $priceSchema ?>",
|
|
|
"availability": "<?php echo $stockSchema ?>"
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
` |
|
|
\ No newline at end of file |