Plugin Uninstall hängt sich auf

Hi, ich habe mich an dieser Anleitung orientiert:

https://developers.shopware.com/developers-guide/attribute-system/?_ga=2.208375377.236356713.1554296588-1725499473.1511125185#schema-operations-and-configuration

…und habe folgendes implementiert:

container->get('shopware_attribute.crud_service');
        $service->update('s_articles_attributes', 'my_column', 'combobox', [
            'label' => 'Field label',
            'supportText' => 'Value under the field',
            'helpText' => 'Value which is displayed inside a help icon tooltip',

            //user has the opportunity to translate the attribute field for each shop
            'translatable' => true,

            //attribute will be displayed in the backend module
            'displayInBackend' => true,

            //in case of multi_selection or single_selection type, article entities can be selected,
            'entity' => 'Shopware\Models\Article\Article',

            //numeric position for the backend view, sorted ascending
            'position' => 100,

            //user can modify the attribute in the free text field module
            'custom' => true,

            //in case of combo box type, defines the selectable values
            'arrayStore' => [
                ['key' => '1', 'value' => 'first value'],
                ['key' => '2', 'value' => 'second value']
            ],
        ]);
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();
        Shopware()->Models()->generateAttributeModels(['s_articles_attributes']);
    }

    public function uninstall(UninstallContext $context)
    {
        $service = $this->container->get('shopware_attribute.crud_service');
        $service->delete('s_articles_attributes', 'my_column');
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();
        Shopware()->Models()->generateAttributeModels( ['s_articles_attributes'] );
    }

}

Wenn ich das Plugin installiere, wird anschließend das neue Feld im Artikel auch wie erwartet angezeigt. Das Problem beginnt mit der Deinstallation. die folgende Ansicht bleibt einfach unendlich lange:

Wo liegt hier mein Fehler?

Hallo,

vielleicht helfen dir diese Artikel weiter: Shopware 5 - Tutorials & FAQs - Fehlermeldungen in Shopware debuggen
Debugging Shopware

Viele Grüße aus Schöppingen

cool Michael Telgmann

Danke, das habe ich alles ausprobiert. Das einzige, was ich finden konnte, ist eine Fehlermeldung in meinem Apache2-Systemlog auf dem Server:

[Thu Apr 04 15:09:51.065793 2019] [:error] [pid 7198] [client 2003:ca:572c:c600:aca7:3238:50e0:4f8e:65379] PHP Warning:
Declaration of HnpwCarpetConfig\\HnpwCarpetConfig::uninstall(HnpwCarpetConfig\\UninstallContext $context) should be compatible with
Shopware\\Components\\Plugin::uninstall(Shopware\\Components\\Plugin\\Context\\UninstallContext $context) in
/var/www/hnpw/dev/shopware/custom/plugins/HnpwCarpetConfig/HnpwCarpetConfig.php on line 53, referer: http://---------.de/backend/

Zeile 53 ist die Zeile mit der allerletzen Klammer. Es ist die, die den Block für class abschließt (Siehe mein erster Post).

Was nun allerdings falsch läuft, kann ich dem leider im Moment nicht entnehmen. Weiß jemand einen Rat?

Das Problem tritt übrigens genau so auf, wenn ich die uninstall Funktion leer lasse:

 public function uninstall(UninstallContext $context)
    {
        /*
        $service = $this->container->get('shopware_attribute.crud_service');
        $service->delete('s_articles_attributes', 'my_column');
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();
        Shopware()->Models()->generateAttributeModels( ['s_articles_attributes'] );
        */
    }

 

Ich habe mein Problem eben entdeckt und natürlich ist es wieder mal komplett dumm ;) Ich habe die folgende Zeile vergessen:

use Shopware\Components\Plugin\Context\UninstallContext;

Es ergibt sich also diese funktionierende Version:

container->get('shopware_attribute.crud_service');
        $service->update('s_articles_attributes', 'my_column', 'combobox', [
            'label' => 'Field label',
            'supportText' => 'Value under the field',
            'helpText' => 'Value which is displayed inside a help icon tooltip',

            //user has the opportunity to translate the attribute field for each shop
            'translatable' => true,

            //attribute will be displayed in the backend module
            'displayInBackend' => true,

            //in case of multi_selection or single_selection type, article entities can be selected,
            'entity' => 'Shopware\Models\Article\Article',

            //numeric position for the backend view, sorted ascending
            'position' => 100,

            //user can modify the attribute in the free text field module
            'custom' => true,

            //in case of combo box type, defines the selectable values
            'arrayStore' => [
                ['key' => '1', 'value' => 'first value'],
                ['key' => '2', 'value' => 'second value']
            ],
        ]);
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();
        Shopware()->Models()->generateAttributeModels(['s_articles_attributes']);
    }

    public function uninstall(UninstallContext $context)
    {
        $service = $this->container->get('shopware_attribute.crud_service');
        $service->delete('s_articles_attributes', 'my_column');
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();
        Shopware()->Models()->generateAttributeModels( ['s_articles_attributes'] );
    }

}

Oh Dear! :wink:

Hallo @hnpw‍,

freut mich, dass du die Ursache selbst gefunden hast.

Dennoch stellt sich mir da die Frage: Nutzt du dafür keine IDE? :slight_smile:
Die hätte dir das nämlich auch schon vorher um die Ohren gehauen oder zumindest gelb markiert als „Hey, das kenne ich nicht?!“.

Gruß,
Patrick  Shopware

Doch, ich benutze PHP-Strom. Ich bin nicht ganz sicher, ob ich das evtl falsch benutze? Die Suggestionen funktionieren schon im Prinzip, aber evtl die für Shopware nicht so richtig. Ichhabe auch das Shopware Plugin installiert:

Hallo,

nutzt du die aktuelle Version 2019.1? Das hätte dir vermutlich diesen Fehler gespart  Wink Siehe What’s New in PhpStorm 2020.3 -> Reworked Imports

Viele Grüße aus Schöppingen

cool Michael Telgmann