SW 5.2 createMenuItem

hi, in einem Plugin erstelle ich ein neues MenuItem

 

$item = $this->createMenuItem(array(
            'label' => 'My-Item',
            'class' => 'sprite-drive-download',
            'active' => 1,
            'position' => 99,
            'action' => 'Index',
            'controller' => 'MyController',
            'parent' => $this->Menu()->findOneBy('label', 'Inhalte'),
        ));
        $this->Menu()->addItem($item);
        $this->Menu()->save();

 

in SW 5.2.1 erhalte ich bei der Installation folgenden fehler:

 

Unable to install, got exception:
An exception occurred while executing 'SELECT t0.id AS id_1, t0.name AS name_2, t0.onclick AS onclick_3, t0.class AS class_4, t0.position AS position_5, t0.active AS active_6, t0.pluginID AS pluginID_7, t0.controller AS controller_8, t0.action AS action_9, t0.shortcut AS shortcut_10, t0.parent AS parent_11, t0.parent AS parent_12, t0.pluginID AS pluginID_13 FROM s_core_menu t0 ORDER BY LIMIT 1':

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1

 

Hat sich hier in SW 5.2 etwas geändert? WIe erstelle ich ein Menüeintrag in SW 5.2?

 

Vielen Dank

@hbee schrieb:

hi, in einem Plugin erstelle ich ein neues MenuItem

 

$item = $this->createMenuItem(array(
‚label‘ => ‚My-Item‘,
‚class‘ => ‚sprite-drive-download‘,
‚active‘ => 1,
‚position‘ => 99,
‚action‘ => ‚Index‘,
‚controller‘ => ‚HqsImport‘,
‚parent‘ => $this->Menu()->findOneBy(‚label‘, ‚Inhalte‘),
));
$this->Menu()->addItem($item);
$this->Menu()->save();

 

in SW 5.2.1 erhalte ich bei der Installation folgenden fehler:

 

Unable to install, got exception:
An exception occurred while executing ‚SELECT t0.id AS id_1, t0.name AS name_2, t0.onclick AS onclick_3, t0.class AS class_4, t0.position AS position_5, t0.active AS active_6, t0.pluginID AS pluginID_7, t0.controller AS controller_8, t0.action AS action_9, t0.shortcut AS shortcut_10, t0.parent AS parent_11, t0.parent AS parent_12, t0.pluginID AS pluginID_13 FROM s_core_menu t0 ORDER BY LIMIT 1‘:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‚LIMIT 1‘ at line 1

 

Hat sich hier in SW 5.2 etwas geändert? WIe erstelle ich ein Menüeintrag in SW 5.2?

 

Vielen Dank

Hallo,

soweit mir bekannt ist, musste auch schon vor Shopware Version 5.2.0 ein Menüpunkt so erstellt werden:

$this->createMenuItem(array(
     'label' => 'Meine Beschriftung',
     'controller' => 'Meincontroller',
     'class' => 'settings--mail-presets',
     'action' => 'Index',
     'active' => 1,
     'parent' => $this->Menu()->findOneBy(['label' => 'Einstellungen'])
));

Der Unterschied liegt hier im Bereich parent und dem Array bei findOneBy(). addItem und save dürfte auch überflüssig sein.

Beste Grüße

Sebastian

2 „Gefällt mir“

hi, vielen Dank, das war’s. findOneBy() hat bislang aber so funktioniert. addItem und save ist nicht nur überflüssig sondern wirft in 5.2 auch einen Fehler.

Hallo,

vor SW 5.2 hatten wir die findOneBy Methode von Doctrine überschrieben, um auch mit zwei Strings zu arbeiten. Dies war aber eher ein unschöner Hack und hat auch mit PHP 7 Probleme bereitet. Deswegen wurde das entfernt und wir nutzen an der Stelle wieder den Doctrine Standard. Im gleichen Zuge sind auch die Methoden raus geflogen, die eh nichts gemacht haben, siehe: shopware/Repository.php at 5.1 · shopware/shopware · GitHub

Viele Grüße aus Schöppingen

cool Michael Telgmann

2 „Gefällt mir“

Da hatte ich Ende Mai bereits für ein Ticket erstellt, dort wurde es auch beantwortet:
https://issues.shopware.com/#/issues/SW-15183

Schöne Grüße,
Niklas

1 „Gefällt mir“