<?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/graphql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.der-mage-experte.de</link>
	<description>Ihr Magento Experte &#38; Entwickler</description>
	<lastBuildDate>Tue, 13 Oct 2026 20:26:53 +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>GraphQL: Varianten eines konfigurierbaren Produktes abfragen</title>
		<link>https://www.der-mage-experte.de/3189/magento2-graphql-varianten-eines-konfigurierbaren-produkts-abfragen/</link>
		<comments>https://www.der-mage-experte.de/3189/magento2-graphql-varianten-eines-konfigurierbaren-produkts-abfragen/#comments</comments>
		<pubDate>Mon, 12 Oct 2026 20:21:49 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Lösungen]]></category>
		<category><![CDATA[GraphQL]]></category>
		<category><![CDATA[konfigurierbares Produkt]]></category>
		<category><![CDATA[Magento 2]]></category>

		<guid isPermaLink="false">https://www.der-mage-experte.de/?p=3189</guid>
		<description><![CDATA[Über Magentos GraphQL lassen sich bei einem konfigurierbaren Produkt neben den normalen Produktdaten auch die konfigurierbaren Attribute und die zugehörigen Child Produkte abfragen. Eine entsprechende Abfrage kann beispielsweise so aussehen: [crayon-6acec39ab27c1/] Der Ausdruck &#8230; on ConfigurableProduct ist ein sogenanntes Inline&#8230;]]></description>
				<content:encoded><![CDATA[<p>Über Magentos GraphQL lassen sich bei einem konfigurierbaren Produkt neben den normalen Produktdaten auch die konfigurierbaren Attribute und die zugehörigen Child Produkte abfragen.</p>
<p>Eine entsprechende Abfrage kann beispielsweise so aussehen:</p><pre class="crayon-plain-tag">{
  products(
    filter: {
      sku: {
        eq: &quot;CONFIGURABLE-SKU&quot;
      }
    }
  ) {
    items {
      sku
      name

      ... on ConfigurableProduct {
        configurable_options {
          attribute_code
          label
          values {
            uid
            label
          }
        }

        variants {
          product {
            sku
            name
            stock_status
          }
        }
      }
    }
  }
}</pre><p>Der Ausdruck <strong>&#8230; on ConfigurableProduct</strong> ist ein sogenanntes Inline Fragment. Die normale Products Abfrage kann unterschiedliche Produkttypen zurückgeben. Über das Fragment werden deshalb zusätzlich die Felder abgefragt, die nur bei einem konfigurierbaren Produkt vorhanden sind.</p>
<p>Über <strong>configurable_options</strong> liefert Magento die verwendeten konfigurierbaren Attribute und deren mögliche Werte. Unter <strong>variants</strong> stehen anschließend die zugeordneten einfachen Produkte inklusive SKU und Lagerstatus zur Verfügung.</p>
<p>Eine Antwort kann dann z.B. so aussehen:</p><pre class="crayon-plain-tag">{
  &quot;data&quot;: {
    &quot;products&quot;: {
      &quot;items&quot;: [
        {
          &quot;sku&quot;: &quot;SHIRT&quot;,
          &quot;name&quot;: &quot;T-Shirt&quot;,
          &quot;configurable_options&quot;: [
            {
              &quot;attribute_code&quot;: &quot;color&quot;,
              &quot;label&quot;: &quot;Farbe&quot;,
              &quot;values&quot;: [
                {
                  &quot;uid&quot;: &quot;Y29uZmlndXJhYmxlLzEwLzUy&quot;,
                  &quot;label&quot;: &quot;Schwarz&quot;
                },
                {
                  &quot;uid&quot;: &quot;Y29uZmlndXJhYmxlLzEwLzUz&quot;,
                  &quot;label&quot;: &quot;Wei&szlig;&quot;
                }
              ]
            }
          ],
          &quot;variants&quot;: [
            {
              &quot;product&quot;: {
                &quot;sku&quot;: &quot;SHIRT-BLACK&quot;,
                &quot;name&quot;: &quot;T-Shirt Schwarz&quot;,
                &quot;stock_status&quot;: &quot;IN_STOCK&quot;
              }
            },
            {
              &quot;product&quot;: {
                &quot;sku&quot;: &quot;SHIRT-WHITE&quot;,
                &quot;name&quot;: &quot;T-Shirt Wei&szlig;&quot;,
                &quot;stock_status&quot;: &quot;OUT_OF_STOCK&quot;
              }
            }
          ]
        }
      ]
    }
  }
}</pre><p>Die Daten können anschließend im Frontend direkt weiterverarbeitet werden. Sollen beispielsweise nur lieferbare Varianten berücksichtigt werden, lässt sich die Antwort entsprechend filtern:</p><pre class="crayon-plain-tag">const product = response.data.products.items[0];

const availableVariants = product.variants
    .filter(variant =&gt; variant.product.stock_status === 'IN_STOCK')
    .map(variant =&gt; ({
        sku: variant.product.sku,
        name: variant.product.name
    }));

console.log(availableVariants);</pre><p>Das Ergebnis enthält in diesem Beispiel nur noch das verfügbare Child Produkt:</p><pre class="crayon-plain-tag">[
  {
    &quot;sku&quot;: &quot;SHIRT-BLACK&quot;,
    &quot;name&quot;: &quot;T-Shirt Schwarz&quot;
  }
]</pre><p>Damit liefert Magento über eine einzige GraphQL Abfrage nicht nur das konfigurierbare Produkt selbst, sondern auch die Struktur seiner Optionen und die dazugehörigen Varianten. Gerade bei eigenen Frontends lässt sich daraus direkt die Auswahl der verfügbaren Produktvarianten aufbauen.</p>]]></content:encoded>
			<wfw:commentRss>https://www.der-mage-experte.de/3189/magento2-graphql-varianten-eines-konfigurierbaren-produkts-abfragen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
