{"id":14341,"date":"2024-04-01T06:34:00","date_gmt":"2024-04-01T06:34:00","guid":{"rendered":"https:\/\/www.bay20.com\/?p=14341"},"modified":"2025-09-24T15:54:50","modified_gmt":"2025-09-24T10:09:50","slug":"wie-konfiguriere-ich-die-standardwerte-der-shopware-6-plugin-konfiguration","status":"publish","type":"post","link":"https:\/\/www.bay20.com\/de\/wie-konfiguriere-ich-die-standardwerte-der-shopware-6-plugin-konfiguration\/","title":{"rendered":"Wie konfiguriere ich die Standardwerte der Shopware 6 Plugin-Konfiguration?"},"content":{"rendered":"\n<p>Dieser Artikel erkl\u00e4rt Ihnen, wie Sie die Standardwerte konfigurieren, die die Benutzer in der Konfiguration Ihres Plugins sehen sollen, sobald sie es installieren und aktivieren. Wenn Sie neu in der Shopware 6 Plugin-Konfiguration sind, empfehle ich Ihnen, zuerst meinen Beitrag \u00fcber die Erstellung einer Konfiguration f\u00fcr Ihr Shopware 6 Plugin zu lesen, um einige grundlegende Kenntnisse mit Beispielen zu erwerben. Dieser Artikel baut auf dem Material des vorherigen Artikels \u201eZugriff auf die Klassen Ihres Plugins w\u00e4hrend der Installation und Aktivierung\u201c auf und erg\u00e4nzt es.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Stellen Sie in der config.xml die Standardwerte des Shopware 6-Plugins ein.<\/h3>\n\n\n\n<p>Um Standardwerte f\u00fcr eine Shopware 6 Plugin-Konfiguration zu konfigurieren, legen Sie diese normalerweise in der Plugin <code>src\/Resources\/config\/config.xml<\/code> file.<\/p>\n\n\n\n<p>Hier finden Sie eine Schritt-f\u00fcr-Schritt-Anleitung zum Einstellen von Standardwerten f\u00fcr Ihre Plugin-Konfiguration:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>config.xml erstellen:<\/strong> Wenn Sie dies noch nicht getan haben, erstellen Sie eine config.xml-Datei im Plugin<code>src\/Resources\/config\/<\/code> directory. Diese Datei enth\u00e4lt die Konfigurationseinstellungen f\u00fcr Ihr Plugin.<\/li><li><strong>Definieren Sie die Konfiguration:<\/strong> Definieren Sie in der Datei config.xml die Konfigurationsstruktur Ihres Plugins. Mit dem Attribut value k\u00f6nnen Sie f\u00fcr jedes Konfigurationsfeld Standardwerte festlegen.<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>Path: &lt;plugin root&gt;\/src\/Resources\/config\/config.xml<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"https:\/\/raw.githubusercontent.com\/shopware\/platform\/master\/src\/Core\/System\/SystemConfig\/Schema\/config.xsd\"&gt;\n    &lt;card&gt;\n        &lt;title&gt;Settings&lt;\/title&gt;\n       &lt;input-field type=\"bool\"&gt;\n            &lt;name&gt;Enabled&lt;\/name&gt;\n            &lt;defaultValue&gt;true&lt;\/defaultValue&gt;\n            &lt;label&gt;Enbale \/ Disable switch&lt;\/label&gt;\n            &lt;label lang=\"de-DE\"&gt;Schalter zum Aktivieren\/Deaktivieren&lt;\/label&gt;\n            &lt;helpText&gt;You can enable or disable the plugin feature according to the sales channel&lt;\/helpText&gt;\n            &lt;helpText lang=\"de-DE\"&gt;Sie k\u00f6nnen die Plugin-Funktion je nach Vertriebskanal aktivieren oder deaktivieren&lt;\/helpText&gt;\n        &lt;\/input-field&gt;     \n    &lt;\/card&gt;\n&lt;\/config&gt;\n<\/code><\/pre>\n\n\n\n<p><strong>Konfigurieren Sie die Plugin-Klasse: <\/strong>In Ihrer Plugin-Klasse (normalerweise in src\/MyPlugin.php) m\u00fcssen Sie die Standard-Konfigurationswerte in der Methode getDefaultConfig() definieren.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nnamespace MyPlugin;\n\nuse Shopware\\Core\\Framework\\Plugin;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\ActivateContext;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\DeactivateContext;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\UninstallContext;\n\nclass MyPlugin extends Plugin\n{\n    public function activate(ActivateContext $activateContext): void\n    {\n        parent::activate($activateContext);\n    }\n\n    public function deactivate(DeactivateContext $deactivateContext): void\n    {\n        parent::deactivate($deactivateContext);\n    }\n\n    public function uninstall(UninstallContext $uninstallContext): void\n    {\n        parent::uninstall($uninstallContext);\n    }\n\n    public function getDefaultConfig(): array\n    {\n        return &#91;\n            'my_plugin.enable_feature' =&gt; true, \/\/ Default value\n        ];\n    }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Konfigurationswerte verwenden: <\/strong>Jetzt k\u00f6nnen Sie auf diese Konfigurationswerte im Code Ihres Plugins zugreifen, indem Sie den SystemConfigService verwenden.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nnamespace MyPlugin;\n\nuse Shopware\\Core\\Framework\\Plugin;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\ActivateContext;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\DeactivateContext;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\UninstallContext;\nuse Shopware\\Core\\Framework\\Plugin\\Context\\UpdateContext;\nuse Shopware\\Core\\System\\SystemConfig\\SystemConfigService;\n\nclass MyPlugin extends Plugin\n{\n    private $systemConfigService;\n\n    public function activate(ActivateContext $activateContext): void\n    {\n        parent::activate($activateContext);\n    }\n\n    public function deactivate(DeactivateContext $deactivateContext): void\n    {\n        parent::deactivate($deactivateContext);\n    }\n\n    public function uninstall(UninstallContext $uninstallContext): void\n    {\n        parent::uninstall($uninstallContext);\n    }\n\n    public function update(UpdateContext $updateContext): void\n    {\n        parent::update($updateContext);\n    }\n\n    public function __construct(SystemConfigService $systemConfigService)\n    {\n        $this-&gt;systemConfigService = $systemConfigService;\n    }\n\n    public function getDefaultConfig(): array\n    {\n        return &#91;\n            'my_plugin.enable_feature' =&gt; true, \/\/ Default value\n        ];\n    }\n\n    public function someFunctionUsingConfig(): void\n    {\n        $enableFeature = $this-&gt;systemConfigService-&gt;get('my_plugin.enable_feature');\n        \/\/ Use the $enableFeature value as needed\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>Wenn Sie diese Schritte befolgen, sollten Sie in der Lage sein, Standardwerte f\u00fcr die Konfiguration Ihres Shopware 6-Plugins zu konfigurieren. Stellen Sie sicher, dass Sie den Cache l\u00f6schen (bin\/console cache:clear), nachdem Sie \u00c4nderungen an der Konfiguration vorgenommen haben, um sicherzustellen, dass die \u00c4nderungen wirksam werden.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"372\" src=\"https:\/\/www.bay20.com\/wp-content\/uploads\/2024\/03\/image-980x372.png\" alt=\"Standardwerte der Shopware 6 Plugin-Konfiguration\" class=\"wp-image-14350\" srcset=\"https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image-980x372.png 980w, https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image-300x114.png 300w, https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image-800x304.png 800w, https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image-768x292.png 768w, https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image-1000x380.png 1000w, https:\/\/www.bay20.com\/de\/wp-content\/uploads\/2024\/03\/image.png 1414w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/figure>\n\n\n\n<p><strong>Bitte kontaktieren Sie uns unter&nbsp;<a href=\"mailto:manish@bay20.com\">manish@bay20.com<\/a>&nbsp;oder rufen Sie uns unter&nbsp;<a href=\"https:\/\/api.whatsapp.com\/send?phone=+918800519180&amp;text=Hi,%20I%20contacted%20you%20through%20your%20website.\" target=\"_blank\" rel=\"noreferrer noopener\">+91-8800519180<\/a>&nbsp;an, wenn Sie Unterst\u00fctzung zu Shopware 6 ben\u00f6tigen. Sie k\u00f6nnen auch die&nbsp;<a href=\"https:\/\/www.bay20.com\/shopware-development-company\/\">Shopware-Entwicklungsseite<\/a>&nbsp;<\/strong>   <strong>besuchen, um die von uns angebotenen Dienstleistungen zu pr\u00fcfen.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dieser Artikel erkl\u00e4rt Ihnen, wie Sie die Standardwerte konfigurieren, die die Benutzer in der Konfiguration Ihres Plugins sehen sollen, sobald sie es installieren und aktivieren. Wenn Sie neu in der Shopware 6 Plugin-Konfiguration sind, empfehle ich Ihnen, zuerst meinen Beitrag \u00fcber die Erstellung einer Konfiguration f\u00fcr Ihr Shopware 6 Plugin zu lesen, um einige grundlegende [&hellip;]<\/p>\n","protected":false},"author":30,"featured_media":14413,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78,115,91],"tags":[],"class_list":["post-14341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shopware","category-shopware-6","category-shopware-6-anleitungen"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/posts\/14341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/comments?post=14341"}],"version-history":[{"count":17,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/posts\/14341\/revisions"}],"predecessor-version":[{"id":17363,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/posts\/14341\/revisions\/17363"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/media\/14413"}],"wp:attachment":[{"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/media?parent=14341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/categories?post=14341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bay20.com\/de\/wp-json\/wp\/v2\/tags?post=14341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}