<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Der Magento Experte</title>
	<atom:link href="https://www.der-mage-experte.de/tag/staffelpreise/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.der-mage-experte.de</link>
	<description>Ihr Magento Experte &#38; Entwickler</description>
	<lastBuildDate>Fri, 03 Apr 2026 09:02:45 +0000</lastBuildDate>
	<language>de-DE</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.6</generator>
	<item>
		<title>Staffelpreise in JavaScript Variable speichern und auslesen</title>
		<link>https://www.der-mage-experte.de/2696/magento2-staffelpreise-in-javascript-variable-speichern-und-auslesen/</link>
		<comments>https://www.der-mage-experte.de/2696/magento2-staffelpreise-in-javascript-variable-speichern-und-auslesen/#comments</comments>
		<pubDate>Fri, 25 Jul 2025 23:11:46 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Lösungen]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[Staffelpreise]]></category>

		<guid isPermaLink="false">https://www.der-mage-experte.de/?p=2696</guid>
		<description><![CDATA[Sie möchten die Magento 2 Staffelpreise eines Produktes (als Array) auslesen und in einer JavaScript Variable speichern, um dann im JavaScript Code darauf zugreifen zu können? Kein Problem, gehen Sie folgendermaßen vor: [crayon-69e45d0d3461d/] Nun können Sie auf die Werte in&#8230;]]></description>
				<content:encoded><![CDATA[<p>Sie möchten die Magento 2 Staffelpreise eines Produktes (als Array) auslesen und in einer JavaScript Variable speichern, um dann im JavaScript Code darauf zugreifen zu können? Kein Problem, gehen Sie folgendermaßen vor:</p><pre class="crayon-plain-tag">&lt;script&gt;
    var tierPrices = &lt;?= json_encode(array_map(fn($t) =&gt; [
        'qty' =&gt; (float)$t-&gt;getQty(),
        'price' =&gt; (float)$t-&gt;getValue(),
        'customer_group_id' =&gt; (int)$t-&gt;getCustomerGroupId()
    ], $product-&gt;getTierPrices())) ?&gt;;
&lt;/script&gt;</pre><p></p>
<p>Nun können Sie auf die Werte in Javascript zugreifen, z.B. mittels einer JavaScript Funktion, welche den Staffelpreis für eine bestimmte Anzahl liefert:</p><pre class="crayon-plain-tag">function getTierPriceForQty(qty) {
    let price = null;
    tierPrices.forEach(function(tier) {
        if (qty &gt;= tier.qty) {
            price = tier.price;
        }
    });
    return price;
}</pre><p>Fertig!</p>]]></content:encoded>
			<wfw:commentRss>https://www.der-mage-experte.de/2696/magento2-staffelpreise-in-javascript-variable-speichern-und-auslesen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TierPriceBox.php für konfigurierbares Produkt überschreiben</title>
		<link>https://www.der-mage-experte.de/2308/magento2-tierpricebox-php-fuer-konfigurierbares-produkt-ueberschreiben/</link>
		<comments>https://www.der-mage-experte.de/2308/magento2-tierpricebox-php-fuer-konfigurierbares-produkt-ueberschreiben/#comments</comments>
		<pubDate>Fri, 28 Jun 2024 08:20:16 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Lösungen]]></category>
		<category><![CDATA[Extension]]></category>
		<category><![CDATA[konfigurierbares Produkt]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[Staffelpreise]]></category>

		<guid isPermaLink="false">https://www.der-mage-experte.de/?p=2308</guid>
		<description><![CDATA[Wenn Sie die Anzeige der Magento 2 Staffelpreise (tier prices) auf der Produktseite eines konfigurierbaren Produktes anpassen möchten, kann es sein, dass Sie die vendor/magento/module-configurable-product/Pricing/Render/TierPriceBox.php Klasse überschreiben müssen. Gehen Sie folgendermassen vor: Fügen Sie den folgenden Inhalt in die di.xml&#8230;]]></description>
				<content:encoded><![CDATA[<p>Wenn Sie die Anzeige der Magento 2 Staffelpreise (tier prices) auf der Produktseite eines konfigurierbaren Produktes anpassen möchten, kann es sein, dass Sie die <strong>vendor/magento/module-configurable-product/Pricing/Render/TierPriceBox.php</strong> Klasse überschreiben müssen. Gehen Sie folgendermassen vor:</p>
<p>Fügen Sie den folgenden Inhalt in die <strong>di.xml</strong> Ihrer Extension ein:</p><pre class="crayon-plain-tag">&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd&quot;&gt;
    &lt;preference for=&quot;Magento\ConfigurableProduct\Pricing\Render\TierPriceBox&quot; type=&quot;Vendor\Module\Pricing\Render\TierPriceBox&quot; /&gt;
&lt;/config&gt;</pre><p>Erstellen Sie nun die Klasse <strong>TierPriceBox.php</strong> in folgendem Pfad: <strong>Vendor/Module/Pricing/Render/TierPriceBox.php</strong></p>
<p>Fügen Sie den folgenden Code in die soeben erstelle Klasse ein und passen Sie z.B. die <strong>toHtml()</strong> Funktion an:</p><pre class="crayon-plain-tag">&lt;?php
/**
 * Copyright &copy; Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Vendor\Module\Pricing\Render;

use Magento\Catalog\Pricing\Price\TierPrice;

/**
 * Responsible for displaying tier price box on configurable product page.
 */
class TierPriceBox extends \Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox
{
    /**
     * @inheritdoc
     */
    public function toHtml()
    {
        // Hide tier price block in case of MSRP or in case when no options with tier price.
        if (!$this-&gt;isMsrpPriceApplicable() &amp;&amp; $this-&gt;isTierPriceApplicable()) {
            return parent::toHtml();
        }
        return '';
    }

    /**
     * Check if at least one of simple products has tier price.
     *
     * @return bool
     */
    private function isTierPriceApplicable()
    {
        $product = $this-&gt;getSaleableItem();
        foreach ($product-&gt;getTypeInstance()-&gt;getUsedProducts($product) as $simpleProduct) {
            if ($simpleProduct-&gt;isSalable() &amp;&amp;
                !empty($simpleProduct-&gt;getPriceInfo()-&gt;getPrice(TierPrice::PRICE_CODE)-&gt;getTierPriceList())
            ) {
                return true;
            }
        }
        return false;
    }
}</pre><p></p>]]></content:encoded>
			<wfw:commentRss>https://www.der-mage-experte.de/2308/magento2-tierpricebox-php-fuer-konfigurierbares-produkt-ueberschreiben/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
