Last active
September 7, 2023 07:41
-
-
Save rickbenetti/7601955 to your computer and use it in GitHub Desktop.
Add header rich snippets to your Magento Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Copyright (c) 2013 Studio Boz | |
* | |
* @project_name Studio Boz | |
* @copyright Copyright (c) 2013 Studio Boz (http://studioboz.com.br) | |
* @author Rick Benetti <[email protected]> | |
* | |
**/ | |
?> | |
<title><?php echo $this->getTitle() ?></title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"/> | |
<meta http-equiv="cleartype" content="on" /> | |
<meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" /> | |
<link rel="icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" /> | |
<link rel="shortcut icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" /> | |
<?php echo $this->getChildHtml('rich.snippets'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- | |
/** | |
* | |
* Copyright (c) 2013 Studio Boz | |
* | |
* @project_name Studio Boz | |
* @copyright Copyright (c) 2013 Studio Boz (http://studioboz.com.br) | |
* @author Rick Benetti <[email protected]> | |
* | |
**/ | |
--> | |
<layout version="0.1.0"> | |
<default> | |
<reference name="head"> | |
<block type="core/template" name="rich.snippets" template="page/html/header/rich.snippets.phtml" /> | |
</reference> | |
</default> | |
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Copyright (c) 2013 Studio Boz | |
* | |
* @project_name Studio Boz | |
* @copyright Copyright (c) 2013 Studio Boz (http://studioboz.com.br) | |
* @author Rick Benetti <[email protected]> | |
* | |
**/ | |
?> | |
<?php | |
$_storeId = Mage::app()->getStore()->getId(); | |
$_helper = $this->helper('catalog/output'); | |
$product = $this->getProduct(); | |
//$productUrl = $product->getUrlModel()->getUrl($product, array('_ignore_category' => true)); | |
$currency = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); | |
$_twitter_username = Mage::getModel('core/variable')->setStoreId($_storeId)->loadByCode('twitter_username')->getValue('plain'); | |
if ($product): | |
$productUrl = $product->getProductUrl(); | |
?> | |
<meta itemprop="url" content="<?php echo $productUrl; ?>" /> | |
<meta itemprop="sku" content="<?php echo $this->getSku() ?>" /> | |
<meta itemprop="price" content="<?php echo number_format($this->getPrice(), 2);?>" /> | |
<meta itemprop="priceCurrency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode();?>" /> | |
<?php if ($this->getReviewsCount()) : ?> | |
<meta itemprop="ratingValue" content="<?php echo $this->getRatingSummary(); ?>"/> | |
<meta itemprop="reviewCount" content="<?php echo $this->getReviewsCount(); ?>" /> | |
<meta itemprop="bestRating" content="100"/> | |
<meta itemprop="worstRating" content="0"/> | |
<?php endif; ?> | |
<!-- Facebook - Open Graph --> | |
<meta property="og:title" content="<?php echo Mage::app()->getWebsite()->getName(); ?>" /> | |
<meta property="og:type" content="product" /> | |
<meta property="og:url" content="<?php echo $productUrl; ?>" /> | |
<meta property="og:price:amount" content="<?php echo Mage::helper('tax')->getPrice($this, $this->getFinalPrice(), true); ?>" /> | |
<meta property="og:price:currency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode() ?>" /> | |
<meta property="og:image" content="<?php echo $this->helper('catalog/image')->init($this, 'image')->resize(600,315); ?>" /> | |
<meta property="og:description" content="<?php echo strip_tags($this->getShortDescription()); ?>" /> | |
<meta property="og:site_name" content="<?php echo Mage::app()->getWebsite()->getName(); ?>" /> | |
<meta property="og:availability" content="<?php echo ($product->isAvailable()) ? 'in stock' : 'out of stock'; ?>" /> | |
<!-- Twitter - Card --> | |
<meta name="twitter:site" content="@<?php echo $_twiter_username; ?>" /> | |
<meta name="twitter:card" content="product"> | |
<meta name="twitter:url" content="<?php echo $productUrl; ?>"> | |
<meta name="twitter:title" content="<?php echo Mage::app()->getWebsite()->getName(); ?>"> | |
<meta name="twitter:description" content="<?php echo strip_tags($this->getShortDescription()); ?>"> | |
<meta name="twitter:image" content="<?php echo $this->helper('catalog/image')->init($this, 'image')->resize(280,150); ?>"> | |
<!-- Google Plus --> | |
<meta itemprop="description" content="<?php echo strip_tags($this->getShortDescription()); ?>"> | |
<meta itemprop="image" content="<?php echo $this->helper('catalog/image')->init($this, 'image')->resize(600,600); ?>"> | |
<meta itemprop="name" content="<?php echo Mage::app()->getWebsite()->getName(); ?>"> | |
<meta itemprop="url" content="<?php echo $this->helper('catalog/product')->getProductUrl($this); ?>"> | |
<?php else: ?> | |
<!-- Facebook - Open Graph --> | |
<meta property="og:title" content="<?php echo $this->getLayout()->getBlock('head')->getTitle() .' « '. Mage::app()->getWebsite()->getName(); ?>" /> | |
<meta property="og:type" content="store" /> | |
<meta property="og:url" content="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" /> | |
<meta property="og:image" content="<?php echo $this->getSkinUrl('images/logo.png') ?>" /> | |
<meta property="og:description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" /> | |
<meta property="og:site_name" content="<?php echo Mage::app()->getWebsite()->getName(); ?>" /> | |
<!-- Twitter - Card --> | |
<meta name="twitter:site" content="@<?php echo $_twitter_username; ?>" /> | |
<meta name="twitter:card" content="summary"> | |
<meta name="twitter:url" content="<?php echo Mage::helper('core/url')->getCurrentUrl();?>"> | |
<meta name="twitter:title" content="<?php echo $this->getLayout()->getBlock('head')->getTitle() .' « '. Mage::app()->getWebsite()->getName(); ?>"> | |
<meta name="twitter:description" content="<?php echo htmlspecialchars($this->getDescription()) ?>"> | |
<meta name="twitter:image" content="<?php echo $this->getSkinUrl('images/logo.png') ?>"> | |
<!-- Google Plus --> | |
<meta itemprop="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>"> | |
<meta itemprop="image" content="<?php echo $this->getSkinUrl('images/logo.png') ?>"> | |
<meta itemprop="name" content="<?php echo Mage::app()->getWebsite()->getName(); ?>"> | |
<meta itemprop="url" content="<?php echo Mage::helper('core/url')->getCurrentUrl();?>"> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment