Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Цены в 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 ...
Содержание 
 Стоимость широких возможностей 
 Реализация 
 Организация сущностей 
 Расширяемость 
 Итоги 
© 2014 Mage...
1 Широкие возможности 
© 2014 Magento, Inc. Page | 4
Разнообразие цен 
 Тип цены 
 Тип продукта 
 Скидки 
 Налоги 
 Настройки расчета 
 Настройки отображения 
© 2014 Mag...
<?php 
$_coreHelper = $this->helper('MagentoCoreHelperData'); 
$weeeHelper = $this->helper('MagentoWeeeHelperData'); 
$pri...
Проблемы 
 Сложность 
 Темплейты 
 Javascript 
 Модулярность 
 Tax 
 Weee 
 И т. д. 
 Дубликаты 
© 2014 Magento, I...
Решения 
 Сложность 
 Концентрация работы с ценами в одном компоненте 
 Организация сущностей 
 Четкая граница между р...
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 
...
Отображение цены 
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) 
 Параметры отображения...
Pricing layout 
Page layout 
© 2014 Magento, Inc. Page | 16 
Pricing 
Render 
Block 
Pricing layout 
Bundle 
Special Price...
Pricing layout fallback 
1. Конкретный тип продукта и цены 
2. Конкретный тип продукта 
3. Конкретный тип цены 
4. Стандар...
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 
Ad...
+1. Параметры отображения 
 Указываются: 
 при обьявление сущностей так 
 при отрисовке конкретного блока цены 
 Досту...
4 Итоги 
© 2014 Magento, Inc. Page | 21
Итоги 
 Модулярность 
 Простота в применении 
 Широкие возможности конфигурации 
 Отсутствие дубликатов кода 
 Отсутс...
<?php 
$_coreHelper = $this->helper('MagentoCoreHelperData'); 
$weeeHelper = $this->helper('MagentoWeeeHelperData'); 
$pri...
Код 
echo $this->getLayout() 
© 2014 Magento, Inc. Page | 24 
->getBlock('product.price.render') 
->render('final_price', ...
Фронт 
© 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
Upcoming SlideShare
Loading in …5
×

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

1,394 views

Published on

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

Published in: Technology
  • Be the first to comment

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

  1. 1. Цены в Magento 2 Magento 2 Pricing Magento is an eBay Inc. company. © 2014 Magento, Inc. All rights reserved.
  2. 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. 3. Содержание  Стоимость широких возможностей  Реализация  Организация сущностей  Расширяемость  Итоги © 2014 Magento, Inc. Page | 3
  4. 4. 1 Широкие возможности © 2014 Magento, Inc. Page | 4
  5. 5. Разнообразие цен  Тип цены  Тип продукта  Скидки  Налоги  Настройки расчета  Настройки отображения © 2014 Magento, Inc. Page | 5 ~500 000
  6. 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. 7. Проблемы  Сложность  Темплейты  Javascript  Модулярность  Tax  Weee  И т. д.  Дубликаты © 2014 Magento, Inc. Page | 7
  8. 8. Решения  Сложность  Концентрация работы с ценами в одном компоненте  Организация сущностей  Четкая граница между расчетом и отрисовкой  Модулярность  DI  Layout  “Adjustment”  Дубликаты © 2014 Magento, Inc. Page | 8
  9. 9. 2 Реализация © 2014 Magento, Inc. Page | 9
  10. 10. Общая схема © 2014 Magento, Inc. Page | 10
  11. 11. Вычисление цены © 2014 Magento, Inc. Page | 11 getPriceInfo() getPrice($priceCode) getAmount () apply() 9.00 0.99 9.99
  12. 12. Отображение цены render() render() apply() © 2014 Magento, Inc. Page | 12 toHtml() toHtml() toHtml()
  13. 13. Фронт © 2014 Magento, Inc. Page | 13 Amounts Price Adjustments
  14. 14. 3 Расширяемость © 2014 Magento, Inc. Page | 14
  15. 15. Точки расширения  Layout (~ Template and Block Pool)  DI (~ Price and Adjustment Models Pool)  Параметры отображения © 2014 Magento, Inc. Page | 15
  16. 16. Pricing layout Page layout © 2014 Magento, Inc. Page | 16 Pricing Render Block Pricing layout Bundle Special Price Configurable Price Tier Price PriceRenderPool & AdjustmentRenderPool
  17. 17. Pricing layout fallback 1. Конкретный тип продукта и цены 2. Конкретный тип продукта 3. Конкретный тип цены 4. Стандартный class/template © 2014 Magento, Inc. Page | 17
  18. 18. DI © 2014 Magento, Inc. Page | 18 Adjustments Pool Tax Price Pool Weee Special Price Custom Price
  19. 19. Расширяемость 4х4 Pricing layout DI © 2014 Magento, Inc. Page | 19 Price Pool Adjustment Pool Price Render Pool Adjustment Render Pool
  20. 20. +1. Параметры отображения  Указываются:  при обьявление сущностей так  при отрисовке конкретного блока цены  Доступны каждому блоку/темплейту  Примеры:  Zone (category, product)  Skip Adjustments  Include Container  Display Label © 2014 Magento, Inc. Page | 20
  21. 21. 4 Итоги © 2014 Magento, Inc. Page | 21
  22. 22. Итоги  Модулярность  Простота в применении  Широкие возможности конфигурации  Отсутствие дубликатов кода  Отсутствие вычислений в темплейтах © 2014 Magento, Inc. Page | 22
  23. 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. 24. Код echo $this->getLayout() © 2014 Magento, Inc. Page | 24 ->getBlock('product.price.render') ->render('final_price', $product, $arguments);
  25. 25. Фронт © 2014 Magento, Inc. Page | 25
  26. 26. 5 © 2014 Magento, Inc. Page | 26 Q&A
  27. 27. Спасибо! © 2014 Magento, Inc. Page | 27 Контакты: email: sivashchenko@ebay.com skype: serg.ivashchenko

×