I have created a module to extend the Tier Pricing template, but the getPrice() is not returning anything therefore the tier pricing array is always null
Any hint is appreciated.
Here is my layout XML:
custom_catalog_product_prices.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<block class="MagentoFrameworkPricingRenderRendererPool" name="render.product.prices">
<arguments>
<argument name="default" xsi:type="array">
<item name="default_render_class" xsi:type="string">MagentoCatalogPricingRenderPriceBox</item>
<item name="default_render_template" xsi:type="string">Magento_Catalog::product/price/default.phtml</item>
<item name="default_amount_render_class" xsi:type="string">MagentoFrameworkPricingRenderAmount</item>
<item name="default_amount_render_template" xsi:type="string">Magento_Catalog::product/price/amount/default.phtml</item>
<item name="prices" xsi:type="array">
<item name="special_price" xsi:type="array">
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/special_price.phtml</item>
</item>
<item name="tier_price" xsi:type="array">
<item name="render_template" xsi:type="string">Custom_ExtendedTierPrice::product/price/tier_prices.phtml</item>
</item>
<item name="final_price" xsi:type="array">
<item name="render_class" xsi:type="string">MagentoCatalogPricingRenderFinalPriceBox</item>
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/final_price.phtml</item>
</item>
<item name="custom_option_price" xsi:type="array">
<item name="amount_render_template" xsi:type="string">Magento_Catalog::product/price/amount/default.phtml</item>
</item>
<item name="configured_price" xsi:type="array">
<item name="render_class" xsi:type="string">MagentoCatalogPricingRenderConfiguredPriceBox</item>
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/configured_price.phtml</item>
</item>
</item>
<!--<item name="adjustments" xsi:type="array"></item>-->
</argument>
</arguments>
</block>
</layout>
- catalog_product_view.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<body>
<block class="MagentoFrameworkPricingRender" name="product.price.render.default">
<arguments>
<argument name="price_render_handle" xsi:type="string">custom_catalog_product_prices</argument>
<argument name="use_link_for_as_low_as" xsi:type="boolean">true</argument>
<!-- set "override" configuration settings here -->
</arguments>
</block>
</body>
</layout>
- tier_prices.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
// phpcs:disable Magento2.Templates.ThisInTemplate
// phpcs:disable Generic.WhiteSpace.ScopeIndent
/** @var MagentoCatalogPricingRenderPriceBox $block */
/** @var MagentoFrameworkViewHelperSecureHtmlRenderer $secureRenderer */
/** @var MagentoFrameworkLocaleLocaleFormatter $localeFormatter*/
/** @var MagentoCatalogPricingPriceTierPrice $tierPriceModel */
$tierPriceModel = $block->getPrice();
$tierPrices = $tierPriceModel->getTierPriceList();
$msrpShowOnGesture = $block->getPriceType('msrp_price')->isShowPriceOnGesture();
$product = $block->getSaleableItem();
?>
<?php if (count($tierPrices)) : ?>
<h1>TEST</h1>
<?php endif; ?>