Skip to content

Instantly share code, notes, and snippets.

@dsalvagni
Created June 13, 2014 01:33
Show Gist options
  • Save dsalvagni/013807fa0577bd486ea5 to your computer and use it in GitHub Desktop.
Save dsalvagni/013807fa0577bd486ea5 to your computer and use it in GitHub Desktop.
Versão 1.7.0.2 - Alterações nos arquivos referentes a preços dos produtos no Magento, utilizando a estrutura de dados do Schema.org: app/design/frontend/base/default/template/bundle/catalog/product/price.phtml; - Mais em http://www.dsalvagni.com.br/magento-rich-snippet-para-produtos
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php $_product = $this->getProduct() ?>
<?php $_priceModel = $_product->getPriceModel() ?>
<?php list($_minimalPriceTax, $_maximalPriceTax) = $_priceModel->getTotalPrices($_product, null, null, false) ?>
<?php list($_minimalPriceInclTax, $_maximalPriceInclTax) = $_priceModel->getTotalPrices($_product, null, true, false) ?>
<?php $_id = $_product->getId() ?>
<?php $idSuffixDeny = array( '-upsell', '_clone' ); ?>
<?php $_weeeTaxAmount = 0; ?>
<?php
if ($_product->getPriceType() == 1) {
$_weeeTaxAmount = Mage::helper('weee')->getAmount($_product);
$_weeeTaxAmountInclTaxes = $_weeeTaxAmount;
if (Mage::helper('weee')->isTaxable()) {
$_attributes = Mage::helper('weee')->getProductWeeeAttributesForRenderer($_product, null, null, null, true);
$_weeeTaxAmountInclTaxes = Mage::helper('weee')->getAmountInclTaxes($_attributes);
}
if ($_weeeTaxAmount && Mage::helper('weee')->typeOfDisplay($_product, array(0, 1, 4))) {
$_minimalPriceTax += $_weeeTaxAmount;
$_minimalPriceInclTax += $_weeeTaxAmountInclTaxes;
}
if ($_weeeTaxAmount && Mage::helper('weee')->typeOfDisplay($_product, 2)) {
$_minimalPriceInclTax += $_weeeTaxAmountInclTaxes;
}
if (Mage::helper('weee')->typeOfDisplay($_product, array(1, 2, 4))) {
$_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
}
}
?>
<div class="price-box">
<?php if ($_product->getPriceView()): ?>
<p class="minimal-price">
<span class="price-label"><?php echo $this->__('As low as') ?>:</span>
<?php if ($this->displayBothPrices()): ?>
<span class="price-excluding-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax:') ?></span>
<span <?php echo (!in_array($this->getIdSuffix(), $idSuffixArray)) ? ' itemprop="price" ' : null; ?>><?php echo Mage::helper('core')->currency($_minimalPriceTax) ?></span>
</span>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<span class="price-including-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax:') ?></span>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
</span>
<?php else: ?>
<?php echo Mage::helper('core')->currency($_minimalPriceTax) ?>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, 2) && $_weeeTaxAmount): ?>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
<?php endif; ?>
<?php endif; ?>
</p>
<?php else: ?>
<?php if ($_minimalPriceTax <> $_maximalPriceTax): ?>
<p class="price-from">
<span class="price-label"><?php echo $this->__('From') ?>:</span>
<?php if ($this->displayBothPrices()): ?>
<span class="price-excluding-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax:') ?></span>
<?php echo Mage::helper('core')->currency($_minimalPriceTax) ?>
</span>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<span class="price-including-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax:') ?></span>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
</span>
<?php else: ?>
<?php echo Mage::helper('core')->currency($_minimalPriceTax) ?>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, 2) && $_weeeTaxAmount): ?>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
<?php endif; ?>
<?php endif; ?>
</p>
<?php
if ($_product->getPriceType() == 1) {
if ($_weeeTaxAmount && Mage::helper('weee')->typeOfDisplay($_product, array(0, 1, 4))) {
$_maximalPriceTax += $_weeeTaxAmount;
$_maximalPriceInclTax += $_weeeTaxAmountInclTaxes;
}
if ($_weeeTaxAmount && Mage::helper('weee')->typeOfDisplay($_product, 2)) {
$_maximalPriceInclTax += $_weeeTaxAmountInclTaxes;
}
}
?>
<p class="price-to">
<span class="price-label"><?php echo $this->__('To') ?>:</span>
<?php if ($this->displayBothPrices()): ?>
<span class="price-excluding-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax:') ?></span>
<span <?php echo (!in_array($this->getIdSuffix(), $idSuffixArray)) ? ' itemprop="price" ' : null; ?>><?php echo Mage::helper('core')->currency($_maximalPriceTax) ?></span>
</span>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<span class="price-including-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax') ?></span>
<?php echo Mage::helper('core')->currency($_maximalPriceInclTax) ?>
</span>
<?php else: ?>
<?php echo Mage::helper('core')->currency($_maximalPriceTax) ?>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, 2) && $_weeeTaxAmount): ?>
<?php echo Mage::helper('core')->currency($_maximalPriceInclTax) ?>
<?php endif; ?>
<?php endif; ?>
</p>
<?php else: ?>
<?php if ($this->displayBothPrices()): ?>
<span class="price-excluding-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Excl. Tax:') ?></span>
<span <?php echo (!in_array($this->getIdSuffix(), $idSuffixArray)) ? ' itemprop="price" ' : null; ?>><?php echo Mage::helper('core')->currency($_minimalPriceTax) ?></span>
</span>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<span class="price-including-tax">
<span class="label"><?php echo Mage::helper('tax')->__('Incl. Tax:') ?></span>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
</span>
<?php else: ?>
<?php echo Mage::helper('core')->currency($_minimalPriceTax) ?>
<?php if ($_weeeTaxAmount && $_product->getPriceType() == 1 && Mage::helper('weee')->typeOfDisplay($_product, array(2, 1, 4))): ?>
<span class="weee">(<small>
<?php $_weeeSeparator = ''; foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, array(2, 4))): ?>
<?php $amount = $_weeeTaxAttribute->getAmount()+$_weeeTaxAttribute->getTaxAmount(); ?>
<?php else: ?>
<?php $amount = $_weeeTaxAttribute->getAmount(); ?>
<?php endif; ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo Mage::helper('core')->currency($amount, true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
</small>)</span>
<?php endif; ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_product, 2) && $_weeeTaxAmount): ?>
<?php echo Mage::helper('core')->currency($_minimalPriceInclTax) ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment