# Config.xml Combo Default Value als Array

**URL:** <https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098>\
**Category:** Programmierung\
**Created:** [29. März 2018 um 10:03 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098 "2018-03-29T10:03:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenit](https://avatars.discourse-cdn.com/v4/letter/z/a87d85/32.png) [@zenit](https://forum.shopware.com/u/zenit)\
**Post date:** [29. März 2018 um 10:03 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/1 "2018-03-29T10:03:51Z")

</div>

Hallo Community,&nbsp;

wie kann man in der config.xml eines Plugins in der xml-Datei beim Element vom Typ Combo bei welchem eine Mehrfachauswahl möglich ist, im Default-Value ein Array mitgeben?

&nbsp;

Variante 1 geht nicht:

```
 A, B, C, D, E, F,

```

Variante 2 geht nicht:

```
A; B; C; D; E; F;

```

Variante 3 geht nicht:

&nbsp;Hier mal das gesamte Combo:

```
            loremIpsum
            Lorem
            Lorem
            A
            Lorem ipsum
            Lorem ipsum
            
                
                    A
                    A
                    A
                
                
                    B
                    B
                    B
                
                
                    C
                    C
                    C
                
                
                    D
                    D
                    D
                
                
                    E
                    E
                    E
                
                
                    F
                    F
                    F
                
            
            
                true

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![tim\_binder](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tim\_binder](https://forum.shopware.com/u/tim_binder)\
**Post date:** [13. November 2018 um 09:13 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/2 "2018-11-13T09:13:24Z")

</div>

Hast du hier mittlerweile eine Lösung gefunden? Stehe vor dem gleichen Problem …

---

<div class="post-metadata">

**Author:** ![tim\_binder](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tim\_binder](https://forum.shopware.com/u/tim_binder)\
**Post date:** [13. November 2018 um 09:19 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/3 "2018-11-13T09:19:05Z")

</div>

Habs herausgefunden - so gehts 🙂 so geht’s nicht - wird nicht als Array übergeben. Vgl. Lösung weiter unten …

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/1/1f149f6a3f37c02e017fb556dccbdd0772bf081a.png)

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [13. November 2018 um 09:19 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/4 "2018-11-13T09:19:13Z")

</div>

In der Install nachträglich das Value anpassen 😃

---

<div class="post-metadata">

**Author:** ![tim\_binder](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tim\_binder](https://forum.shopware.com/u/tim_binder)\
**Post date:** [13. November 2018 um 10:42 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/5 "2018-11-13T10:42:24Z")

</div>

Stimmt 🙂

Hab ich sogar an ner anderen Stelle im Plugin schon gemacht&nbsp; ![Foot-in-Mouth](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/foot-in-mouth.png "Foot-in-Mouth")

Für alle die drauf stoßen - so z.B.:

```
    public function install(InstallContext $context)
    {
        // set days
        $daysArray = [
            0 => 'monday',
            1 => 'friday'
        ];
        $this->updateConfigValue($daysArray, 'config_element_name');
    }

    /**
     * update config value in database
     *
     * @param $value
     * @param $key
     * @param string $shopId
     * @throws \Zend_Db_Adapter_Exception
     */
    private function updateConfigValue($value, $key, $shopId = '')
    {
        if (!empty($shopId)) {
            $sql = "UPDATE `s_core_config_values` val
                    INNER JOIN `s_core_config_elements` el ON el.`id` = val.`element_id`
                    SET val.`value` = ? 
                    WHERE el.`name` = ? AND val.`shop_id` = ?";
            Shopware()->Db()->query($sql, array(serialize($value), $key, $shopId));
        } else {
            $sql = "UPDATE `s_core_config_elements` SET `value` = ? WHERE `name` = ?";
            Shopware()->Db()->query($sql, array(serialize($value), $key));
        }
    }

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [13. November 2018 um 10:48 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/6 "2018-11-13T10:48:46Z")

</div>

Viel sauberer und einfacher würde es über den Doctrine weg gehen 🙂

---

<div class="post-metadata">

**Author:** ![benda](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@benda](https://forum.shopware.com/u/benda)\
**Post date:** [26. Januar 2019 um 14:04 UTC](https://forum.shopware.com/t/config-xml-combo-default-value-als-array/52098/7 "2019-01-26T14:04:14Z")

</div>

> [@Shyim schrieb:](https://forum.shopware.com/profile/20792/Shyim "Shyim")
> 
> Viel sauberer und einfacher würde es über den Doctrine weg gehen ![:)](https://dub1.discourse-cdn.com/flex013/resources/emoji/smile.png ":)")

Kannst du ein Beispiel hier posten? ![Thumb-Up](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/thumb-up.png "Thumb-Up")&nbsp;
