Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W Wiki
  • Project overview
    • Project overview
    • Details
    • Activity
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
Collapse sidebar
  • Tutoriais
  • Wiki
  • Wiki
    • Magento
  • SimpleSchema

Last edited by Jonatan Machado Aug 27, 2019
Page history

SimpleSchema

<?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>
Clone repository
  • Gitlab
    • Comandos
  • Hotfix
    • og:image
  • Magento
    • Htaccess
    • MagentoCronChecker
    • Robots
    • SimpleSchema
    • Soap v2 Tester
    • gitignore
  • Migração
    • leg.br
  • Padrões
    • eslint
    • prettier
  • Plugins
    • Adicionar informações extras ao texto copiado da web
  • QueryCommerce
  • Servidores
    • Cloudways
    • DnsMadeEasy
View All Pages