[AttributeSystem - Gelöst] Neues Attribute Feld hinzufügen

Hallo,

ich versuche ein neues Feld über ein Plugin zu registrieren, aber es wird mir nicht angezeigt weder bei „Freitext-Verwaltung“ noch bei den Artikeln oder in der Datanbank. ’
Mein Frage ist was fehlt noch oder ob man noch ein Event Subscriben muss. 

Habe das nach diesen Guide geschrieben: Attribute system

 

public function install()
    {
            $this->createAtrributeFields();
    }

 

/**
     * Create new Attribute Field
     */
    protected function createAtrributeFields() {
        try {
            $service = $this->container->get(‚shopware_attribute.crud_service‘);

            $service->update(‚s_articles_attributes‘, ‚article_custom_id‘, ‚combobox‘, [
                ‚label‘ => ‚Custom ID‘,
                ‚supportText‘ => ‚Custom ID‘,
                ‚helpText‘ => ‚Set custom ID‘,

                //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‘ => 5,

                //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‘]
                ],
            ], ‚energy_id‘, false);
        } catch (Exception $e) {
            return array(‚success‘ => false, ‚message‘ =>  $e->getMessage());
        }
    }

Vielen Dank,
Brian 

Hi,

Sieht an sich korrekt aus… Möglicherweise gibt es aber eine Exception die nicht gezeigt wird…
Bist Du sicher, dass der try-Block ausgeführt wird?

Hi, 

ja, weil alle anderen Methoden korrekt ausgeführt werden. 
Aber die Frage ist, warum keine Exception aufgerufen wird, obwohl es die erste Methode ist in der Install Mehtod und nichts bewirkt. 

 

Also bei mir sieht das so aus - vielleicht hilft es Dir ja:

/**
     * Add customer attributes
     */
    private function customer() {

        // Get the service
        $attributeService = Shopware()->Container()->get('shopware_attribute.crud_service');

        // Price list number
        $attributeService->update('s_user_attributes', 'pname_pricelist_number', 'integer');


        // Creation date
        $attributeService->update('s_user_attributes', 'pname_created', 'datetime', [
                'label' => 'Customer created date',
                'translatable' => false,
                'displayInBackend' => true,
                'position' => 600
            ]
        );

        // Modification date
        $attributeService->update('s_user_attributes', 'pname_modified', 'datetime', [
                'label' => 'Customer modified date',
                'translatable' => false,
                'displayInBackend' => true,
                'position' => 700
            ]
        );

        // Rebuild attribute models
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();

        Shopware()->Models()->generateAttributeModels(
            array('s_articles_attributes')
        );

    }

 

1 „Gefällt mir“

// Rebuild attribute models $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl(); $metaDataCache->deleteAll(); Shopware()->Models()->generateAttributeModels( array(‘s_articles_attributes’) );

Vielen Dank, das hat mir gefehlt.