Skip to content

Instantly share code, notes, and snippets.

@caovillanueva
Last active March 22, 2021 16:03
Show Gist options
  • Save caovillanueva/e69f8981a8ba723b29d6ad5922734b06 to your computer and use it in GitHub Desktop.
Save caovillanueva/e69f8981a8ba723b29d6ad5922734b06 to your computer and use it in GitHub Desktop.
[PS1.7 Schema.org Rich Snippets] All snippets for Prestashop #PS17
/public_html/themes/THEME_/templates/_partials
---------------------------------------------
{if $page.page_name !='index'} <-- Just add this conditional to avoid error in index page.That's all.
<nav data-depth="{$breadcrumb.count}" class="breadcrumb hidden-sm-down">
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
{block name='breadcrumb'}
{foreach from=$breadcrumb.links item=path name=breadcrumb}
{block name='breadcrumb_item'}
{if not $smarty.foreach.breadcrumb.last}
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a itemprop="item" href="{$path.url}"><span itemprop="name">{$path.title}</span></a>
<meta itemprop="position" content="{$smarty.foreach.breadcrumb.iteration}">
</li>
{elseif isset($path.title)}
<li>
<span>{$path.title}</span>
</li>
{/if}
{/block}
{/foreach}
{/block}
</ol>
</nav>
{/if}
/public_html/themes/THEME_/templates/_partials
---------------------------------------------
{block name="rich_snippets"}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Organization",
"name" : "{$shop.name|escape:'html':'UTF-8'}",
"url" : "{$urls.base_url}",
"logo" : {
"@type":"ImageObject",
"url":"{$shop.logo}"
}
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Store",
"address": {
"@type": "PostalAddress",
"addressLocality": "Québec",
"addressRegion": "CA",
"postalCode": "J3G 5M6",
"streetAddress": "885, Belmont, McMasterville"
},
"name": "{$shop.name}",
"priceRange": "$$$",
"telephone": "1-866-666-6933",
"url": "{$urls.base_url}",
"image": "{$urls.base_url}img/votrelogo-logo-1574096800.jpg"
}
</script>
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"WebPage",
"isPartOf": {
"@type":"WebSite",
"url": "{$urls.base_url}",
"name": "{$shop.name}"
},
"name": "{$page.meta.title}",
"url": "{$urls.base_url}"
}
</script>
{if $page.page_name =='index'}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "WebSite",
"name": "{$shop.name}",
"url": "{$urls.base_url}",
"potentialAction": {
"@type": "SearchAction",
"target": "{$urls.base_url}recherche?controller=search&s={literal}{search_term_string}{/literal}",
"query-input": "required name=search_term_string"
}
}
</script>
{/if}
{/block}
/public_html/themes/MY_THEME/templates/catalog/_partials
--------------------------------------------------------------
<div class="current-price">
<span itemprop="price" content="{$product.rounded_display_price}">{$product.price}</span>
<meta itemprop="priceValidUntil" content="{'Y'|date}-12-31" /> <!-- Add this -->
<meta itemprop="url" content="{$product.url}"> <!-- Add this -->
...
Just Before {block name='product_without_taxes'} put the follow code for brand and MPN
<div itemprop="brand" itemscope itemtype="http://schema.org/Brand">
<meta itemprop="name" content="{if $product.id_manufacturer}{Manufacturer::getNameById($product.id_manufacturer)}
{else}
{$shop.name}
{/if}">
</div>
{if !empty($product.reference_to_display)}
<meta itemprop="mpn" content="{$product.reference_to_display}" /> <!-- If not have mpn, use the reference val. -->
{/if}
...
/domains/votrelogo.ca/public_html/themes/MY_THEME/templates/catalog/_partials/miniatures
iF PRODUCTS NOT BELONG FROM THE SAME CATEGORY, U WILL GET THE FOLLOR ERROR IN URL VARIABLE:
"All values provided for url must point to the same page."
...
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="invisible">
<meta itemprop="priceCurrency" content="{$currency.iso_code}" />
<meta itemprop="price" content="{$product.price_amount}" />
<meta itemprop="priceValidUntil" content="{'Y'|date}-12-31" />
<meta itemprop="url" content="{$urls.base_url}">
<link itemprop="availability" href="http://schema.org/InStock" />
</div>
<div itemprop="brand" itemscope itemtype="http://schema.org/Brand">
<meta itemprop="name" content="{if $product.id_manufacturer}{Manufacturer::getNameById($product.id_manufacturer)}
{else}
{$shop.name}
{/if}">
</div>
<meta itemprop="sku" content="{$product.reference}" />
<meta itemprop="mpn" content="{if $product.reference}{$product.reference}{else}{$product.mpn}{/if}" /><!-- If not have mpn, use the reference val. -->
{if $product->ean13}
<meta itemprop="gtin13" content="{$product->ean13|escape:'html':'UTF-8'}" />
{/if}
<meta itemprop="image" content="{$product.cover.large.url}" />
<meta itemprop="description" content="{$product.description|strip_tags}" />
...
optional
{if $product.condition == 'new'}
<meta itemprop="itemCondition" content="new" />
{else if $product.condition == 'used'}
<meta itemprop="itemCondition" content="used" />
{else}
<meta itemprop="itemCondition" content="refurbished" />
{/if}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment