Advertisement
rubendivall

PrestaShop-SEO-Snippets/microdata-json.tpl

May 26th, 2016
1,655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smarty 3.26 KB | None | 0 0
  1. {* Structured Data Json - LD Microdata for Prestashop 1.6.X
  2. *
  3. * Add this code in your smarty global.tpl/header.tpl file to show Organization, WebPage, Website and Product Microdata in ld+json format.
  4. * Requires Prestashop 'productcomments' module for review stars ratings.
  5. * by Ruben Divall @rubendivall http://www.rubendivall.com
  6. *}
  7. <script type="application/ld+json">
  8. {
  9.     "@context" : "http://schema.org",
  10.     "@type" : "Organization",
  11.     "name" : "{$shop_name|escape:'html':'UTF-8'}",
  12.     "url" : "{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}",
  13.     "logo" : {
  14.         "@type":"ImageObject",
  15.         "url":"{$logo_url}"
  16.     }
  17. }
  18. </script>
  19. <script type="application/ld+json">
  20. {
  21.     "@context":"http://schema.org",
  22.     "@type":"WebPage",
  23.     "isPartOf": {
  24.         "@type":"WebSite",
  25.         "url":  "{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}",
  26.         "name": "{$shop_name|escape:'html':'UTF-8'}"
  27.     },
  28.     "name": "{$meta_title}",
  29.     "url":  "{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{trim($smarty.server.REQUEST_URI,'/')}{else}{$base_dir}{trim($smarty.server.REQUEST_URI,'/')}{/if}"
  30. }
  31. </script>
  32. {if $page_name =='index'}
  33. <script type="application/ld+json">
  34. {
  35.     "@context": "http://schema.org",
  36.     "@type":  "WebSite",
  37.     "url":  "{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}",
  38.     "image" : {
  39.     "@type":  "ImageObject",
  40.     "url":  "{$logo_url}"
  41.     },
  42.     "potentialAction": {
  43.         "@type": "SearchAction",
  44.         "target": "{$link->getPageLink('search', null, null, null, false, null,  true)|escape:'html':'UTF-8'}?search_query={literal}{search_term}{/literal}",
  45.         "query-input": "required name=search_term"
  46.     }
  47. }
  48. </script>
  49. {/if}
  50.  
  51. {if $page_name == 'product'}
  52. <script type="application/ld+json">
  53.     {  
  54.     "@context": "http://schema.org/",
  55.     "@type": "Product",
  56.     "name": "{$product->name}",
  57.     "image": "{$link->getImageLink($product->link_rewrite, $cover.id_image, 'home_default')|escape:'html':'UTF-8'}",
  58.     "description": "{$product->description_short|strip_tags|escape:'html':'UTF-8'}",
  59.     {if $product->reference}
  60.     "mpn": "{$product->reference|escape:'html':'UTF-8'}",
  61.     {/if}
  62.     {if $product->ean13}
  63.     "gtin13": "{$product->ean13|escape:'html':'UTF-8'}",
  64.     {/if}
  65.     {if $product_manufacturer->name}
  66.     "brand": {
  67.         "@type": "Thing",
  68.         "name": "{$product_manufacturer->name|escape:'html':'UTF-8'}"
  69.     },
  70.     {/if}
  71.     {if $nbComments && $ratings.avg}
  72.     "aggregateRating": {
  73.         "@type": "AggregateRating",
  74.         "ratingValue": "{$ratings.avg|round:1|escape:'html':'UTF-8'}",
  75.         "reviewCount": "{$nbComments|escape:'html':'UTF-8'}"
  76.     },
  77.     {/if}
  78.     "offers": {
  79.         "@type": "Offer",
  80.         "priceCurrency": "{$currency->iso_code}",
  81.         "price": "{$product->getPrice(true, $smarty.const.NULL, 2)|round:'2'}",
  82.    
  83.         {if $product->condition == 'new'}"itemCondition": "http://schema.org/NewCondition",{/if}
  84.         {if $product->condition == 'used'}"itemCondition": "http://schema.org/UsedCondition",{/if}
  85.         {if $product->condition == 'refurbished'}"itemCondition": "http://schema.org/RefurbishedCondition",{/if}
  86.         {if $product->quantity > 0}"availability": "http://schema.org/InStock",{/if}
  87.         "seller": {
  88.             "@type": "Organization",
  89.             "name": "{$shop_name|escape:'html':'UTF-8'}"
  90.             }
  91.     }
  92. }
  93. </script>
  94. {/if}
  95. {** End of Structured Data Json - LD Microdata for Prestashop 1.6.X **}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement