Magento is an eBay Inc. company. © 2014 Magento, Inc. All rights reserved.
Цены в Magento 2
Magento 2 Pricing
© 2014 Magento, Inc. Page | 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 | 3
Содержание
Стоимость широких возможностей
Реализация
Организация сущностей
Расширяемость
Итоги
© 2014 Magento, Inc. Page | 4© 2014 Magento, Inc. Page | 4
1 Широкие возможности
© 2014 Magento, Inc. Page | 5
Разнообразие цен
Тип цены
Тип продукта
Скидки
Налоги
Настройки расчета
Настройки отображения
~500 000
© 2014 Magento, Inc. Page | 6
<?php
$_coreHelper = $this->helper('Magento\Core\Helper\Data');
$weeeHelper = $this->helper('Magento\Weee\Helper\Data');
$priceHelper = $this->helper('Magento\Catalog\Helper\Product\Price');
/* @var $_coreHelper \Magento\Core\Helper\Data */
/* @var $weeeHelper \Magento\Weee\Helper\Data */
/* @var $priceHelper Magento\Catalog\Helper\Product\Price */
$_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(\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, \Magento\Weee\Model\Tax::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>
</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, 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"><?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="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"><?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>
<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>
</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="<?php echo $_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>
© 2014 Magento, Inc. Page | 7
Проблемы
Сложность
Темплейты
Javascript
Модулярность
Tax
Weee
И т. д.
Дубликаты
© 2014 Magento, Inc. Page | 8
Решения
Сложность
Концентрация работы с ценами в одном компоненте
Организация сущностей
Четкая граница между расчетом и отрисовкой
Модулярность
DI
Layout
“Adjustment”
Дубликаты
© 2014 Magento, Inc. Page | 9© 2014 Magento, Inc. Page | 9
2 Реализация
© 2014 Magento, Inc. Page | 10
Общая схема
Price rendering
Price calculation
Price
Render
© 2014 Magento, Inc. Page | 11
Вычисление цены
Product
Price Info
Price
AmountAdjustment
getPriceInfo()
getPrice($priceCode)
getAmount ()
apply()
9.00
0.99
9.99
© 2014 Magento, Inc. Page | 12
Отображение цены
PriceBox
Pricing
Render
Amount Render
Ajustment Render
render()
render()
apply()
toHtml()
toHtml()
toHtml()
© 2014 Magento, Inc. Page | 13
Фронт
Amounts
Adjustments
Price
© 2014 Magento, Inc. Page | 14© 2014 Magento, Inc. Page | 14
3 Расширяемость
© 2014 Magento, Inc. Page | 15
Точки расширения
Layout (~ Template and Block Pool)
DI (~ Price and Adjustment Models Pool)
Параметры отображения
© 2014 Magento, Inc. Page | 16
Pricing layout
Page layout
PricingRenderBlock
Pricing layout
BundleSpecial Price
ConfigurablePrice
Tier Price
PriceRenderPool & AdjustmentRenderPool
© 2014 Magento, Inc. Page | 17
Pricing layout fallback
Default
Price
Product
Product&Price1. Конкретный тип продукта и цены
2. Конкретный тип продукта
3. Конкретный тип цены
4. Стандартный class/template
© 2014 Magento, Inc. Page | 18
DI
Adjustments Pool
Tax
Price Pool
Weee
Special Price
Custom Price
© 2014 Magento, Inc. Page | 19
Расширяемость 4х4
DIPricing layout
Price Pool
Adjustment Pool
Price Render Pool
Adjustment Render Pool
© 2014 Magento, Inc. Page | 20
+1. Параметры отображения
Указываются:
при обьявление сущностей так
при отрисовке конкретного блока цены
Доступны каждому блоку/темплейту
Примеры:
Zone (category, product)
Skip Adjustments
Include Container
Display Label
© 2014 Magento, Inc. Page | 21© 2014 Magento, Inc. Page | 21
4 Итоги
© 2014 Magento, Inc. Page | 22
Итоги
Модулярность
Простота в применении
Широкие возможности конфигурации
Отсутствие дубликатов кода
Отсутствие вычислений в темплейтах
© 2014 Magento, Inc. Page | 23
<?php
$_coreHelper = $this->helper('Magento\Core\Helper\Data');
$weeeHelper = $this->helper('Magento\Weee\Helper\Data');
$priceHelper = $this->helper('Magento\Catalog\Helper\Product\Price');
/* @var $_coreHelper \Magento\Core\Helper\Data */
/* @var $weeeHelper \Magento\Weee\Helper\Data */
/* @var $priceHelper Magento\Catalog\Helper\Product\Price */
$_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(\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, \Magento\Weee\Model\Tax::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>
</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, 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"><?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="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"><?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>
<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>
</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="<?php echo $_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>
© 2014 Magento, Inc. Page | 24
Код
echo $this->getLayout() ->getBlock('product.price.render') ->render('final_price', $product, $arguments);
© 2014 Magento, Inc. Page | 25
Фронт
© 2014 Magento, Inc. Page | 26© 2014 Magento, Inc. Page | 26
5
Q&A
© 2014 Magento, Inc. Page | 27© 2014 Magento, Inc. Page | 27
Спасибо!
Контакты:email: [email protected]: serg.ivashchenko