# Legacy Plugin funktioniert seit Update auf 5.7 nicht mehr

**URL:** <https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971>\
**Category:** Shopware 5\
**Created:** [26. August 2021 um 09:04 UTC](https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971 "2021-08-26T09:04:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![screenteam](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/screenteam/32/14633_2.png) [@screenteam](https://forum.shopware.com/u/screenteam)\
**Post date:** [26. August 2021 um 09:04 UTC](https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971/1 "2021-08-26T09:04:26Z")

</div>

Hallo zusammen,

ich habe hier ein kleines legacy Plugin, was seit dem Update auf 5.7 nicht mehr funktioniert.

Meine Bootstrap.php:

```auto
<?php

use ShopwarePlugins\LnetTextbausteine\Bundle\StoreFrontBundle\ListProductService;

class Shopware_Plugins_Frontend_LnetTextbausteine_Bootstrap extends Shopware_Components_Plugin_Bootstrap {

    public function getVersion() {
        return '1.0.0';
    }

    public function getLabel() {
        return 'Plugin: Ersetzt Textbausteine in der Storefront';
    }

    public function afterInit() {
        $this->get('loader')->registerNamespace('ShopwarePlugins\LnetTextbausteine', $this->Path());
    }

    public function install() {
 
        $this->createConfiguration();
        $events = [
            'Enlight_Bootstrap_AfterInitResource_shopware_storefront.list_product_service' => 'decorateListProductService',
        ];
        foreach ($events as $event => $listener) {
            $this->subscribeEvent($event, $listener);
        }
        return true;

    }

    public function decorateListProductService()
    {
       
        $coreService = $this->get('shopware_storefront.list_product_service');

        $newService = new ListProductService($coreService);
        Shopware()->Container()->set('shopware_storefront.list_product_service', $newService);
    }

    public function uninstall() {

        return true;
    }

    public function createConfiguration() {

        $form = $this->Form();

        $form->setElement('text', 'namespace',
            array(
                'label' => 'Standard Namespace',
                'description' => 'Der Standard Namespace in dem Textbausteine gesucht werden',
                'value' => 'products',
            )
        );
        $form->setElement('text', 'fields',
            array(
                'label' => 'zu ersetzende Felder',
                'description' => 'Felder welche ersetzt werden sollen (Datenbanktitel)',
                'value' => 'description_long',
            )
        );

        return true;
    }

}

```

Zeile 16 $this-\>get(‚ **loader** ‘) war vorher $this-\>get(‚ **Loader** ‘). Ich hatte im Forum gelesen, dass das ein beliebter Fehler war. Funktioniert leider trotzdem nicht.

Und das ist meine Bundle/StoreFrontBundle/ListProductService.php:

```auto

namespace ShopwarePlugins\LnetTextbausteine\Bundle\StoreFrontBundle;

use Shopware\Bundle\StoreFrontBundle\Service\ListProductServiceInterface;
use Shopware\Bundle\StoreFrontBundle\Struct;

class ListProductService implements ListProductServiceInterface
{
    /**
     * @var ListProductServiceInterface
     */
    private $coreService;

    private $config;

    /**
     * @param ListProductServiceInterface $coreService
     */
    function __construct(
        ListProductServiceInterface $coreService
    ) {
        $this->coreService = $coreService;
        $this->config = Shopware()->Plugins()->Frontend()->LnetTextbausteine()->Config();

    }

    public function getList(array $numbers, Struct\ProductContextInterface $context)
    {

        $products = $this->coreService->getList($numbers, $context);
        foreach ($products as $product) {
            foreach (explode(',', $this->config->fields) as $field) {
             
                switch($field) {
                    case 'description_long':
                        $addText = '';
                        $productAttributes = $product->getAttributes()['core']->get('attr1');
                        if(!empty($productAttributes)) {
                            $items = explode(',', $productAttributes);
                            $addText = '<ul>';
                            foreach ($items as $item) {
                                $addText .= '<li>[['.trim($item).']]</li>';
                            }
                            $addText .= '</ul>';
                        }
                        $product->setLongDescription(preg_replace_callback('/\[\[([^]]+)\]\]/', array($this, 'replaceTextBlock'), $product->getLongDescription().$addText));
                        break;
                }
            }
        }

        return $products;
    }

    public function get($number, Struct\ProductContextInterface $context)
    {
        $products = $this->getList([$number], $context);
        return array_shift($products);
    }

    protected function replaceTextBlock($text) {
        $config = Shopware()->Plugins()->Frontend()->LnetTextbausteine()->Config();

        if (strpos($text[1], '/')) {
            preg_match('/.*\/(.*)/', $text[1], $matches);
            $key = $matches[1];
            $namespace = substr($matches[0], 0, strlen($matches[0])-strlen($matches[1])-1);
        } else {
            $key = $text[1];
            if (strlen($config->namespace) > 0) {
                $namespace = $config->namespace;
            } else {
                $namespace = '';
            }
        }

        $query = 'SELECT `value` FROM s_core_snippets WHERE `namespace` = "'.$namespace.'" AND `name` = "'.$key.'"';
        $result = Shopware()->Db()->fetchRow($query);
        if ($result) {
            return $result['value'];
        } else {
            return $text[0];
        }
    }

}

```

Über jeden Hinweis wäre ich sehr dankbar!

Viele Grüße  
Frank

---

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [26. August 2021 um 09:40 UTC](https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971/2 "2021-08-26T09:40:01Z")

</div>

Hast du denn eine Fehlermeldung oder wie äußert sich „funktioniert nicht“?

---

<div class="post-metadata">

**Author:** ![screenteam](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/screenteam/32/14633_2.png) [@screenteam](https://forum.shopware.com/u/screenteam)\
**Post date:** [26. August 2021 um 09:58 UTC](https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971/3 "2021-08-26T09:58:43Z")

</div>

Hallo Moritz, eine Fehlermeldung gibt es leider nicht. Normalerweise ersetzt das Plugin einen [[Textblock]] mit einem Text aus den Snippets. Und das funktioniert nicht mehr. Was ich bisher rausgefunden habe ist, dass die Funktion decorateListProductService() in der Bootstrap.php nicht aufgerufen wird. Daher wäre meine Vermutung, dass eventuell das Event **Enlight\_Bootstrap\_AfterInitResource\_shopware\_storefront.list\_product\_service** nicht mehr stimmt!?

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [27. August 2021 um 11:09 UTC](https://forum.shopware.com/t/legacy-plugin-funktioniert-seit-update-auf-5-7-nicht-mehr/89971/4 "2021-08-27T11:09:36Z")

</div>

Hallo Frank,

das Problem ist bereits bekannt und wird mit dem nächsten Update 5.7.3 behoben. Hier das dazugehörige Ticket: [Shopware Issuetracker](https://issues.shopware.com/issues/SW-26092)

Viele Grüße aus Schöppingen  
Michael Telgmann
