Skip to content

Instantly share code, notes, and snippets.

@rickbenetti
Last active December 18, 2015 00:59
Show Gist options
  • Select an option

  • Save rickbenetti/5701062 to your computer and use it in GitHub Desktop.

Select an option

Save rickbenetti/5701062 to your computer and use it in GitHub Desktop.
## Magento1column.php, 2columns-left.php, 2columns-right.php and 3columns.php use this head tagging.Price produto page taggingHead content to add rich snippets to all pages by home or product page.
<?php if ( Mage::registry('current_product') ) : ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>" prefix="og: http://ogp.me/ns#" itemscope itemtype="http://schema.org/Product">
<?php elseif( Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ): ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>" prefix="og: http://ogp.me/ns#" itemscope itemtype="http://schema.org/Store">
<?php endif; ?>
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
/* PRICE */
$symbolMoney = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
$fromPrice = number_format($_product->getPrice(), 2, ',', '.');
$toPrice = number_format($_product->getFinalPrice(), 2, ',', '.');
?>
<div class="offers" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="priceCurrency" content="<?php echo $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode(); ?>"/>
<?php if($fromPrice == $toPrice): ?>
<p class="price-box">
<span class="price-label">Por </span>
<strong itemprop="price" class="new-price price-value">
<?php echo "<span>". $symbolMoney . "</span>" . $fromPrice; ?>
</strong>
</p>
<?php else: ?>
<p class="price-box special-price">
<link itemprop="itemCondition" href="http://schema.org/NewCondition">
<meta itemprop="priceCurrency" content="BRL" />
<span class="price">
<span class="price-label old-price">De </span>
<del class="old-price price-value">
<?php echo "<span>". $symbolMoney . "</span>" . $fromPrice; ?>
</del>
</span>
<span class="price">
<span class="price-label new-price">Por </span>
<strong itemprop="price" class="new-price price-value">
<?php echo "<span>". $symbolMoney . "</span>" . $toPrice; ?>
</strong>
</span>
</p>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment