Цены в Magento 2 
Magento 2 Pricing 
Magento is an eBay Inc. company. © 2014 Magento, Inc. All rights reserved.
О себе 
 Backend разработчик Magento 
 В Magento 2.5 года 
 Проэкты 
 Magento Testing Framework 
 Filesystem 
 Full Page Cache 
 Pricing 
 Service Layer 
 Сейчас занимаюсь 
 MTF Parallel Run и Magento 2 Sales 
© 2014 Magento, Inc. Page | 2
Содержание 
 Стоимость широких возможностей 
 Реализация 
 Организация сущностей 
 Расширяемость 
 Итоги 
© 2014 Magento, Inc. Page | 3
1 Широкие возможности 
© 2014 Magento, Inc. Page | 4
Разнообразие цен 
 Тип цены 
 Тип продукта 
 Скидки 
 Налоги 
 Настройки расчета 
 Настройки отображения 
© 2014 Magento, Inc. Page | 5 
~500 000
<?php 
$_coreHelper = $this->helper('MagentoCoreHelperData'); 
$weeeHelper = $this->helper('MagentoWeeeHelperData'); 
$priceHelper = $this->helper('MagentoCatalogHelperProductPrice'); 
/* @var $_coreHelper MagentoCoreHelperData */ 
/* @var $weeeHelper MagentoWeeeHelperData */ 
/* @var $priceHelperMagentoCatalogHelperProductPrice */ 
$_product = $this->getProduct(); 
$_storeId = $_product->getStoreId(); 
$_id = $_product->getId(); 
$_weeeSeparator = ''; 
$_simplePricesTax = ($priceHelper->displayPriceIncludingTax() || $priceHelper->displayBothPrices()); 
$_minimalPriceValue = $_product->getMinimalPrice(); 
$_minimalPrice = $priceHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); 
?> 
<?php $_weeeTaxAmount = $weeeHelper->getAmountForDisplay($_product); ?> 
<?php if ($weeeHelper->typeOfDisplay($_product, array(MagentoWeeeModelTax::DISPLAY_INCL_DESCR, 
MagentoWeeeModelTax::DISPLAY_EXCL_DESCR_INCL, 4))): ?> 
<?php $_weeeTaxAmount = $weeeHelper->getAmount($_product); ?> 
<?php $_weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($_product); ?> 
<?php endif; ?> 
<?php $_weeeTaxAmountInclTaxes = $_weeeTaxAmount; ?> 
<?php if ($weeeHelper->isTaxable() && !$priceHelper->priceIncludesTax($_storeId)): ?> 
<?php $_attributes = $weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true); ?> 
<?php $_weeeTaxAmountInclTaxes = $weeeHelper->getAmountInclTaxes($_attributes); ?> 
<?php endif; ?> 
<div class="price-box"> 
<?php $_price = $priceHelper->getPrice($_product, $_product->getPrice()) ?> 
<?php $_regularPrice = $priceHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?> 
<?php $_finalPrice= $priceHelper->getPrice($_product, $_product->getFinalPrice()) ?> 
<?php $_finalPriceInclTax = $priceHelper->getPrice($_product, $_product->getFinalPrice(), true) ?> 
<?php $_weeeDisplayType = $weeeHelper->getPriceDisplayType(); ?> 
<?php if ($_finalPrice >= $_price): ?> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + 
$_weeeTaxAttribute->getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price, true, false) ?> 
</span> 
</span> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
<?php else: ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php if ($_finalPrice == $_price): ?> 
<?php echo $_coreHelper->currency($_price, true, false) ?> 
<?php else: ?> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
<?php endif; ?> 
</span> 
© 2014 Magento, </span> 
Inc. Page | 6 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> 
</span> 
</span> 
<?php endif; ?> 
<?php else: ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- 
>getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br /> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<?php else: ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php if ($_finalPrice== $_price): ?> 
<?php echo $_coreHelper->currency($_price, true, true) ?> 
<?php else: ?> 
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?> 
<?php endif; ?> 
</span> 
<?php endif; ?> 
<?php endif; ?> 
<?php else: /* if ($_finalPrice == $_price): */ ?> 
<?php $_originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($_product); ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?phpecho __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</p> 
<?php endif; ?> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- 
>getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</span> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: // excl. ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice, true, false) ?> 
</span> 
</p> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?phpecho __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?phpecho __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</p> 
<?php endif; ?> 
<?php endif; ?> 
<?php endif; /* if ($_finalPrice == $_price): */ ?> 
<?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_product->getFinalPrice()): ?> 
<?php $_minimalPriceDisplayValue = $_minimalPrice; ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, array(0, 1, 4))): ?> 
<?php $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount; ?> 
<?php endif; ?> 
<?php if ($this->getUseLinkForAsLowAs()):?> 
<a href="<?phpecho $_product->getProductUrl(); ?>" class="minimal-price-link"> 
<?php else:?> 
<span class="minimal-price-link"> 
<?php endif?> 
<span class="label"><?php echo __('As low as:') ?></span> 
<span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_minimalPriceDisplayValue, true, false) ?> 
</span> 
<?php if ($this->getUseLinkForAsLowAs()):?> 
</a> 
<?php else:?> 
</span> 
<?php endif?> 
<?php endif; /* if ($this->getDisplayMinimalPrice() && $_minimalPrice && $_minimalPrice < $_finalPrice): */ ?> 
</div>
Проблемы 
 Сложность 
 Темплейты 
 Javascript 
 Модулярность 
 Tax 
 Weee 
 И т. д. 
 Дубликаты 
© 2014 Magento, Inc. Page | 7
Решения 
 Сложность 
 Концентрация работы с ценами в одном компоненте 
 Организация сущностей 
 Четкая граница между расчетом и отрисовкой 
 Модулярность 
 DI 
 Layout 
 “Adjustment” 
 Дубликаты 
© 2014 Magento, Inc. Page | 8
2 Реализация 
© 2014 Magento, Inc. Page | 9
Общая схема 
© 2014 Magento, Inc. Page | 10
Вычисление цены 
© 2014 Magento, Inc. Page | 11 
getPriceInfo() 
getPrice($priceCode) 
getAmount () 
apply() 
9.00 
0.99 
9.99
Отображение цены 
render() 
render() 
apply() 
© 2014 Magento, Inc. Page | 12 
toHtml() 
toHtml() 
toHtml()
Фронт 
© 2014 Magento, Inc. Page | 13 
Amounts 
Price 
Adjustments
3 Расширяемость 
© 2014 Magento, Inc. Page | 14
Точки расширения 
 Layout (~ Template and Block Pool) 
 DI (~ Price and Adjustment Models Pool) 
 Параметры отображения 
© 2014 Magento, Inc. Page | 15
Pricing layout 
Page layout 
© 2014 Magento, Inc. Page | 16 
Pricing 
Render 
Block 
Pricing layout 
Bundle 
Special Price 
Configurable 
Price 
Tier Price 
PriceRenderPool & AdjustmentRenderPool
Pricing layout fallback 
1. Конкретный тип продукта и цены 
2. Конкретный тип продукта 
3. Конкретный тип цены 
4. Стандартный class/template 
© 2014 Magento, Inc. Page | 17
DI 
© 2014 Magento, Inc. Page | 18 
Adjustments 
Pool 
Tax 
Price Pool 
Weee 
Special Price 
Custom Price
Расширяемость 4х4 
Pricing layout DI 
© 2014 Magento, Inc. Page | 19 
Price Pool 
Adjustment 
Pool 
Price Render 
Pool 
Adjustment 
Render Pool
+1. Параметры отображения 
 Указываются: 
 при обьявление сущностей так 
 при отрисовке конкретного блока цены 
 Доступны каждому блоку/темплейту 
 Примеры: 
 Zone (category, product) 
 Skip Adjustments 
 Include Container 
 Display Label 
© 2014 Magento, Inc. Page | 20
4 Итоги 
© 2014 Magento, Inc. Page | 21
Итоги 
 Модулярность 
 Простота в применении 
 Широкие возможности конфигурации 
 Отсутствие дубликатов кода 
 Отсутствие вычислений в темплейтах 
© 2014 Magento, Inc. Page | 22
<?php 
$_coreHelper = $this->helper('MagentoCoreHelperData'); 
$weeeHelper = $this->helper('MagentoWeeeHelperData'); 
$priceHelper = $this->helper('MagentoCatalogHelperProductPrice'); 
/* @var $_coreHelper MagentoCoreHelperData */ 
/* @var $weeeHelper MagentoWeeeHelperData */ 
/* @var $priceHelperMagentoCatalogHelperProductPrice */ 
$_product = $this->getProduct(); 
$_storeId = $_product->getStoreId(); 
$_id = $_product->getId(); 
$_weeeSeparator = ''; 
$_simplePricesTax = ($priceHelper->displayPriceIncludingTax() || $priceHelper->displayBothPrices()); 
$_minimalPriceValue = $_product->getMinimalPrice(); 
$_minimalPrice = $priceHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); 
?> 
<?php $_weeeTaxAmount = $weeeHelper->getAmountForDisplay($_product); ?> 
<?php if ($weeeHelper->typeOfDisplay($_product, array(MagentoWeeeModelTax::DISPLAY_INCL_DESCR, 
MagentoWeeeModelTax::DISPLAY_EXCL_DESCR_INCL, 4))): ?> 
<?php $_weeeTaxAmount = $weeeHelper->getAmount($_product); ?> 
<?php $_weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($_product); ?> 
<?php endif; ?> 
<?php $_weeeTaxAmountInclTaxes = $_weeeTaxAmount; ?> 
<?php if ($weeeHelper->isTaxable() && !$priceHelper->priceIncludesTax($_storeId)): ?> 
<?php $_attributes = $weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true); ?> 
<?php $_weeeTaxAmountInclTaxes = $weeeHelper->getAmountInclTaxes($_attributes); ?> 
<?php endif; ?> 
<div class="price-box"> 
<?php $_price = $priceHelper->getPrice($_product, $_product->getPrice()) ?> 
<?php $_regularPrice = $priceHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?> 
<?php $_finalPrice= $priceHelper->getPrice($_product, $_product->getFinalPrice()) ?> 
<?php $_finalPriceInclTax = $priceHelper->getPrice($_product, $_product->getFinalPrice(), true) ?> 
<?php $_weeeDisplayType = $weeeHelper->getPriceDisplayType(); ?> 
<?php if ($_finalPrice >= $_price): ?> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + 
$_weeeTaxAttribute->getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price, true, false) ?> 
</span> 
</span> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
<?php else: ?> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php if ($_finalPrice == $_price): ?> 
<?php echo $_coreHelper->currency($_price, true, false) ?> 
<?php else: ?> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
<?php endif; ?> 
</span> 
© 2014 Magento, </span> 
Inc. Page | 23 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> 
</span> 
</span> 
<?php endif; ?> 
<?php else: ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- 
>getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br /> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> 
</span> 
<?php else: ?> 
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php if ($_finalPrice== $_price): ?> 
<?php echo $_coreHelper->currency($_price, true, true) ?> 
<?php else: ?> 
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?> 
<?php endif; ?> 
</span> 
<?php endif; ?> 
<?php endif; ?> 
<?php else: /* if ($_finalPrice == $_price): */ ?> 
<?php $_originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($_product); ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?phpecho __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</p> 
<?php endif; ?> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> 
</span> 
</span> 
<span class="weee">( 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<?php echo $_weeeSeparator; ?> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- 
>getTaxAmount(), true, true); ?> 
<?php $_weeeSeparator = ' + '; ?> 
<?php endforeach; ?> 
)</span> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice, true, false) ?> 
</span> 
</p> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?php echo __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</span> 
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> 
<span class="weee"> 
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> 
</span> 
<?php endforeach; ?> 
<span class="price-including-tax"> 
<span class="label"><?php echo __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: // excl. ?> 
<p class="old-price"> 
<span class="price-label"><?php echo __('Regular Price:') ?></span> 
<span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_regularPrice, true, false) ?> 
</span> 
</p> 
<?php if ($priceHelper->displayBothPrices()): ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price-excluding-tax"> 
<span class="label"><?phpecho __('Excl. Tax:') ?></span> 
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</span> 
<span class="price-including-tax"> 
<span class="label"><?phpecho __('Incl. Tax:') ?></span> 
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> 
</span> 
</span> 
</p> 
<?php else: ?> 
<p class="special-price"> 
<span class="price-label"><?php echo __('Special Price:') ?></span> 
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?> 
</span> 
</p> 
<?php endif; ?> 
<?php endif; ?> 
<?php endif; /* if ($_finalPrice == $_price): */ ?> 
<?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_product->getFinalPrice()): ?> 
<?php $_minimalPriceDisplayValue = $_minimalPrice; ?> 
<?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, array(0, 1, 4))): ?> 
<?php $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount; ?> 
<?php endif; ?> 
<?php if ($this->getUseLinkForAsLowAs()):?> 
<a href="<?phpecho $_product->getProductUrl(); ?>" class="minimal-price-link"> 
<?php else:?> 
<span class="minimal-price-link"> 
<?php endif?> 
<span class="label"><?php echo __('As low as:') ?></span> 
<span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> 
<?php echo $_coreHelper->currency($_minimalPriceDisplayValue, true, false) ?> 
</span> 
<?php if ($this->getUseLinkForAsLowAs()):?> 
</a> 
<?php else:?> 
</span> 
<?php endif?> 
<?php endif; /* if ($this->getDisplayMinimalPrice() && $_minimalPrice && $_minimalPrice < $_finalPrice): */ ?> 
</div>
Код 
echo $this->getLayout() 
© 2014 Magento, Inc. Page | 24 
->getBlock('product.price.render') 
->render('final_price', $product, $arguments);
Фронт 
© 2014 Magento, Inc. Page | 25
5 
© 2014 Magento, Inc. Page | 26 
Q&A
Спасибо! 
© 2014 Magento, Inc. Page | 27 
Контакты: 
email: sivashchenko@ebay.com 
skype: serg.ivashchenko

Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2

  • 1.
    Цены в Magento2 Magento 2 Pricing Magento is an eBay Inc. company. © 2014 Magento, Inc. All rights reserved.
  • 2.
    О себе Backend разработчик Magento  В Magento 2.5 года  Проэкты  Magento Testing Framework  Filesystem  Full Page Cache  Pricing  Service Layer  Сейчас занимаюсь  MTF Parallel Run и Magento 2 Sales © 2014 Magento, Inc. Page | 2
  • 3.
    Содержание  Стоимостьшироких возможностей  Реализация  Организация сущностей  Расширяемость  Итоги © 2014 Magento, Inc. Page | 3
  • 4.
    1 Широкие возможности © 2014 Magento, Inc. Page | 4
  • 5.
    Разнообразие цен Тип цены  Тип продукта  Скидки  Налоги  Настройки расчета  Настройки отображения © 2014 Magento, Inc. Page | 5 ~500 000
  • 6.
    <?php $_coreHelper =$this->helper('MagentoCoreHelperData'); $weeeHelper = $this->helper('MagentoWeeeHelperData'); $priceHelper = $this->helper('MagentoCatalogHelperProductPrice'); /* @var $_coreHelper MagentoCoreHelperData */ /* @var $weeeHelper MagentoWeeeHelperData */ /* @var $priceHelperMagentoCatalogHelperProductPrice */ $_product = $this->getProduct(); $_storeId = $_product->getStoreId(); $_id = $_product->getId(); $_weeeSeparator = ''; $_simplePricesTax = ($priceHelper->displayPriceIncludingTax() || $priceHelper->displayBothPrices()); $_minimalPriceValue = $_product->getMinimalPrice(); $_minimalPrice = $priceHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); ?> <?php $_weeeTaxAmount = $weeeHelper->getAmountForDisplay($_product); ?> <?php if ($weeeHelper->typeOfDisplay($_product, array(MagentoWeeeModelTax::DISPLAY_INCL_DESCR, MagentoWeeeModelTax::DISPLAY_EXCL_DESCR_INCL, 4))): ?> <?php $_weeeTaxAmount = $weeeHelper->getAmount($_product); ?> <?php $_weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($_product); ?> <?php endif; ?> <?php $_weeeTaxAmountInclTaxes = $_weeeTaxAmount; ?> <?php if ($weeeHelper->isTaxable() && !$priceHelper->priceIncludesTax($_storeId)): ?> <?php $_attributes = $weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true); ?> <?php $_weeeTaxAmountInclTaxes = $weeeHelper->getAmountInclTaxes($_attributes); ?> <?php endif; ?> <div class="price-box"> <?php $_price = $priceHelper->getPrice($_product, $_product->getPrice()) ?> <?php $_regularPrice = $priceHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?> <?php $_finalPrice= $priceHelper->getPrice($_product, $_product->getFinalPrice()) ?> <?php $_finalPriceInclTax = $priceHelper->getPrice($_product, $_product->getFinalPrice(), true) ?> <?php $_weeeDisplayType = $weeeHelper->getPriceDisplayType(); ?> <?php if ($_finalPrice >= $_price): ?> <?php if ($priceHelper->displayBothPrices()): ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price, true, false) ?> </span> </span> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> <?php else: ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice == $_price): ?> <?php echo $_coreHelper->currency($_price, true, false) ?> <?php else: ?> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> <?php endif; ?> </span> © 2014 Magento, </span> Inc. Page | 6 <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> </span> </span> <?php endif; ?> <?php else: ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- >getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br /> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <?php else: ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice== $_price): ?> <?php echo $_coreHelper->currency($_price, true, true) ?> <?php else: ?> <?php echo $_coreHelper->currency($_finalPrice, true, true) ?> <?php endif; ?> </span> <?php endif; ?> <?php endif; ?> <?php else: /* if ($_finalPrice == $_price): */ ?> <?php $_originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($_product); ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <?php if ($priceHelper->displayBothPrices()): ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?phpecho __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php else: ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </p> <?php endif; ?> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- >getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </span> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php else: // excl. ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?> </span> </p> <?php if ($priceHelper->displayBothPrices()): ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?phpecho __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?phpecho __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> </span> </span> </p> <?php else: ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </p> <?php endif; ?> <?php endif; ?> <?php endif; /* if ($_finalPrice == $_price): */ ?> <?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_product->getFinalPrice()): ?> <?php $_minimalPriceDisplayValue = $_minimalPrice; ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, array(0, 1, 4))): ?> <?php $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount; ?> <?php endif; ?> <?php if ($this->getUseLinkForAsLowAs()):?> <a href="<?phpecho $_product->getProductUrl(); ?>" class="minimal-price-link"> <?php else:?> <span class="minimal-price-link"> <?php endif?> <span class="label"><?php echo __('As low as:') ?></span> <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_minimalPriceDisplayValue, true, false) ?> </span> <?php if ($this->getUseLinkForAsLowAs()):?> </a> <?php else:?> </span> <?php endif?> <?php endif; /* if ($this->getDisplayMinimalPrice() && $_minimalPrice && $_minimalPrice < $_finalPrice): */ ?> </div>
  • 7.
    Проблемы  Сложность  Темплейты  Javascript  Модулярность  Tax  Weee  И т. д.  Дубликаты © 2014 Magento, Inc. Page | 7
  • 8.
    Решения  Сложность  Концентрация работы с ценами в одном компоненте  Организация сущностей  Четкая граница между расчетом и отрисовкой  Модулярность  DI  Layout  “Adjustment”  Дубликаты © 2014 Magento, Inc. Page | 8
  • 9.
    2 Реализация ©2014 Magento, Inc. Page | 9
  • 10.
    Общая схема ©2014 Magento, Inc. Page | 10
  • 11.
    Вычисление цены ©2014 Magento, Inc. Page | 11 getPriceInfo() getPrice($priceCode) getAmount () apply() 9.00 0.99 9.99
  • 12.
    Отображение цены render() render() apply() © 2014 Magento, Inc. Page | 12 toHtml() toHtml() toHtml()
  • 13.
    Фронт © 2014Magento, Inc. Page | 13 Amounts Price Adjustments
  • 14.
    3 Расширяемость ©2014 Magento, Inc. Page | 14
  • 15.
    Точки расширения Layout (~ Template and Block Pool)  DI (~ Price and Adjustment Models Pool)  Параметры отображения © 2014 Magento, Inc. Page | 15
  • 16.
    Pricing layout Pagelayout © 2014 Magento, Inc. Page | 16 Pricing Render Block Pricing layout Bundle Special Price Configurable Price Tier Price PriceRenderPool & AdjustmentRenderPool
  • 17.
    Pricing layout fallback 1. Конкретный тип продукта и цены 2. Конкретный тип продукта 3. Конкретный тип цены 4. Стандартный class/template © 2014 Magento, Inc. Page | 17
  • 18.
    DI © 2014Magento, Inc. Page | 18 Adjustments Pool Tax Price Pool Weee Special Price Custom Price
  • 19.
    Расширяемость 4х4 Pricinglayout DI © 2014 Magento, Inc. Page | 19 Price Pool Adjustment Pool Price Render Pool Adjustment Render Pool
  • 20.
    +1. Параметры отображения  Указываются:  при обьявление сущностей так  при отрисовке конкретного блока цены  Доступны каждому блоку/темплейту  Примеры:  Zone (category, product)  Skip Adjustments  Include Container  Display Label © 2014 Magento, Inc. Page | 20
  • 21.
    4 Итоги ©2014 Magento, Inc. Page | 21
  • 22.
    Итоги  Модулярность  Простота в применении  Широкие возможности конфигурации  Отсутствие дубликатов кода  Отсутствие вычислений в темплейтах © 2014 Magento, Inc. Page | 22
  • 23.
    <?php $_coreHelper =$this->helper('MagentoCoreHelperData'); $weeeHelper = $this->helper('MagentoWeeeHelperData'); $priceHelper = $this->helper('MagentoCatalogHelperProductPrice'); /* @var $_coreHelper MagentoCoreHelperData */ /* @var $weeeHelper MagentoWeeeHelperData */ /* @var $priceHelperMagentoCatalogHelperProductPrice */ $_product = $this->getProduct(); $_storeId = $_product->getStoreId(); $_id = $_product->getId(); $_weeeSeparator = ''; $_simplePricesTax = ($priceHelper->displayPriceIncludingTax() || $priceHelper->displayBothPrices()); $_minimalPriceValue = $_product->getMinimalPrice(); $_minimalPrice = $priceHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); ?> <?php $_weeeTaxAmount = $weeeHelper->getAmountForDisplay($_product); ?> <?php if ($weeeHelper->typeOfDisplay($_product, array(MagentoWeeeModelTax::DISPLAY_INCL_DESCR, MagentoWeeeModelTax::DISPLAY_EXCL_DESCR_INCL, 4))): ?> <?php $_weeeTaxAmount = $weeeHelper->getAmount($_product); ?> <?php $_weeeTaxAttributes = $weeeHelper->getProductWeeeAttributesForDisplay($_product); ?> <?php endif; ?> <?php $_weeeTaxAmountInclTaxes = $_weeeTaxAmount; ?> <?php if ($weeeHelper->isTaxable() && !$priceHelper->priceIncludesTax($_storeId)): ?> <?php $_attributes = $weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true); ?> <?php $_weeeTaxAmountInclTaxes = $weeeHelper->getAmountInclTaxes($_attributes); ?> <?php endif; ?> <div class="price-box"> <?php $_price = $priceHelper->getPrice($_product, $_product->getPrice()) ?> <?php $_regularPrice = $priceHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax) ?> <?php $_finalPrice= $priceHelper->getPrice($_product, $_product->getFinalPrice()) ?> <?php $_finalPriceInclTax = $priceHelper->getPrice($_product, $_product->getFinalPrice(), true) ?> <?php $_weeeDisplayType = $weeeHelper->getPriceDisplayType(); ?> <?php if ($_finalPrice >= $_price): ?> <?php if ($priceHelper->displayBothPrices()): ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price, true, false) ?> </span> </span> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> <?php else: ?> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice == $_price): ?> <?php echo $_coreHelper->currency($_price, true, false) ?> <?php else: ?> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> <?php endif; ?> </span> © 2014 Magento, </span> Inc. Page | 23 <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> </span> </span> <?php endif; ?> <?php else: ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- >getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br /> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?> </span> <?php else: ?> <span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php if ($_finalPrice== $_price): ?> <?php echo $_coreHelper->currency($_price, true, true) ?> <?php else: ?> <?php echo $_coreHelper->currency($_finalPrice, true, true) ?> <?php endif; ?> </span> <?php endif; ?> <?php endif; ?> <?php else: /* if ($_finalPrice == $_price): */ ?> <?php $_originalWeeeTaxAmount = $weeeHelper->getOriginalAmount($_product); ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 0)): // including ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <?php if ($priceHelper->displayBothPrices()): ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?phpecho __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php else: ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </p> <?php endif; ?> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice + $_originalWeeeTaxAmount, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice + $_weeeTaxAmount, true, false) ?> </span> </span> <span class="weee">( <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <?php echo $_weeeSeparator; ?> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute- >getTaxAmount(), true, true); ?> <?php $_weeeSeparator = ' + '; ?> <?php endforeach; ?> )</span> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php elseif ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?> </span> </p> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?php echo __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </span> <?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?> <span class="weee"> <?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?> </span> <?php endforeach; ?> <span class="price-including-tax"> <span class="label"><?php echo __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax + $_weeeTaxAmountInclTaxes, true, false) ?> </span> </span> </p> <?php else: // excl. ?> <p class="old-price"> <span class="price-label"><?php echo __('Regular Price:') ?></span> <span class="price" id="old-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?> </span> </p> <?php if ($priceHelper->displayBothPrices()): ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price-excluding-tax"> <span class="label"><?phpecho __('Excl. Tax:') ?></span> <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </span> <span class="price-including-tax"> <span class="label"><?phpecho __('Incl. Tax:') ?></span> <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?> </span> </span> </p> <?php else: ?> <p class="special-price"> <span class="price-label"><?php echo __('Special Price:') ?></span> <span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_finalPrice, true, false) ?> </span> </p> <?php endif; ?> <?php endif; ?> <?php endif; /* if ($_finalPrice == $_price): */ ?> <?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_product->getFinalPrice()): ?> <?php $_minimalPriceDisplayValue = $_minimalPrice; ?> <?php if ($_weeeTaxAmount && $weeeHelper->typeOfDisplay($_product, array(0, 1, 4))): ?> <?php $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount; ?> <?php endif; ?> <?php if ($this->getUseLinkForAsLowAs()):?> <a href="<?phpecho $_product->getProductUrl(); ?>" class="minimal-price-link"> <?php else:?> <span class="minimal-price-link"> <?php endif?> <span class="label"><?php echo __('As low as:') ?></span> <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_minimalPriceDisplayValue, true, false) ?> </span> <?php if ($this->getUseLinkForAsLowAs()):?> </a> <?php else:?> </span> <?php endif?> <?php endif; /* if ($this->getDisplayMinimalPrice() && $_minimalPrice && $_minimalPrice < $_finalPrice): */ ?> </div>
  • 24.
    Код echo $this->getLayout() © 2014 Magento, Inc. Page | 24 ->getBlock('product.price.render') ->render('final_price', $product, $arguments);
  • 25.
    Фронт © 2014Magento, Inc. Page | 25
  • 26.
    5 © 2014Magento, Inc. Page | 26 Q&A
  • 27.
    Спасибо! © 2014Magento, Inc. Page | 27 Контакты: email: sivashchenko@ebay.com skype: serg.ivashchenko