PHPackages                             wemea/sylius-menu-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wemea/sylius-menu-plugin

ActiveSylius-plugin[Utility &amp; Helpers](/categories/utility)

wemea/sylius-menu-plugin
========================

Plugin allowing to manage Store menus from the Back Office in Sylius

v1.2.0(1y ago)52.3k[4 PRs](https://github.com/wemea-fr/SyliusMenuPlugin/pulls)MITPHPPHP ^8.1CI failing

Since Nov 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wemea-fr/SyliusMenuPlugin)[ Packagist](https://packagist.org/packages/wemea/sylius-menu-plugin)[ RSS](/packages/wemea-sylius-menu-plugin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (38)Versions (10)Used By (0)

[![License](https://camo.githubusercontent.com/bb6b2902c4de8d82806fe09a8f496bc87211cf126d1434fc449821a09a894288/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656d65612f73796c6975732d6d656e752d706c7567696e2e737667)](https://github.com/wemea-fr/SyliusMenuPlugin/blob/main/LICENSE.txt)[![CI - Build](https://github.com/wemea-fr/SyliusMenuPlugin/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/wemea-fr/SyliusMenuPlugin/actions/workflows/build.yml)[![Version](https://camo.githubusercontent.com/c4cf1208a6ea8dcf1b50eef9e4e63bcd1295fb4ec29fa8d1cb286afff162ffe2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656d65612f73796c6975732d6d656e752d706c7567696e2e737667)](https://packagist.org/packages/wemea/sylius-menu-plugin)[![Total Downloads](https://camo.githubusercontent.com/a2816e4673f34780effca7237358ce457eb684efaebeb045036207e6bbd0ff56/68747470733a2f2f706f7365722e707567782e6f72672f77656d65612f73796c6975732d6d656e752d706c7567696e2f646f776e6c6f616473)](https://packagist.org/packages/wemea/sylius-menu-plugin)

 [ ![](doc/logo.png) ](https://www.wemea.fr)

Sylius Menu Plugin
==================

[](#sylius-menu-plugin)

Plugin allow to manage Shop menus from the Back Office

Features:
---------

[](#features)

- Create/Delete menu with commands :
    - `wemea:menu:create `
    - `wemea:menu:delete `
- Manage visibility of menus
- Manage menu item (link, title, description, order/priority, icon)
- Default link types :
    - Custom: put any link inside
    - Product: choose link to a product and path is generated dynamically
    - Taxon: choose link to a taxononmy and path is generated dynamically

[![Menu render in Shop page](doc/sample_footer_menus.png)](doc/sample_footer_menus.png)

[![Administration of menus](doc/admin_menus.png)](doc/admin_menus.png)

[![Administration of menu](doc/admin_menu_edit.png)](doc/admin_menu_edit.png)

[![Administration of menu items](doc/admin_menu_items.png)](doc/admin_menu_items.png)

[![Administration of menu item](doc/admin_menu_item_create.png)](doc/admin_menu_item_create.png)

Summary
-------

[](#summary)

1. [Installation](#installation)
2. [Usage](#usage)
    1. [Add new menu](#add-a-menu)
    2. [Change default route mapping](#change-default-resource-route-mapping)
    3. [Add Custom resource link](#add-new-link-type-to-another-resource)
3. [Use menu fixtures](#use-menu-fixtures)

Installation
------------

[](#installation)

1. Require plugin with composer:

    ```
    composer require wemea/sylius-menu-plugin
    ```
2. Add followings to your `config/bundles.php` if not already automatically added:

    ```
    Wemea\SyliusMenuPlugin\WemeaSyliusMenuPlugin::class => ['all' => true],
    ```
3. Import config in your `config/packages/_sylius.yaml`:

    ```
    imports:
        [...]
        - { resource: "@WemeaSyliusMenuPlugin/Resources/config/app/config.yml" }
    ```
4. Import routes in your `config/routes.yml`:

    ```
     wemea_menu_routing:
       resource: "@WemeaSyliusMenuPlugin/Resources/config/routing.yml"
    ```
5. Add menus into your template. Check [Usage - Add a menu](#add-a-menu) for more information
6. Run [integration test](#running-plugin-integration-tests-only).

    ⚠️ There are integration tests only for admin part. **You should** add your owned tests for shop part.

Usage
-----

[](#usage)

### Add a menu

[](#add-a-menu)

*Tips* :

> Menus can only be created and removed with Symfony command to avoid shop admin removed accidentally a menu and block the UI. Menus can be disabled on the BO.

1. Create new menu

    Run `bin/console wemea:menu:create `

    You can run `bin/console wemea:menu:create --help` to view available options
2. Add this menu in your template: add this where you want to introduce menu to your page(s)

    ```
        {{ render(controller('wemea_sylius_menu.controller.render_menu::renderAction', {
               'code': ''
        })) }}
    ```

    By default, the menu use `@WemeaSyliusMenuPlugin/Shop/Menu/_default.html.twig`. If you want to use your own template, add tempalte option on render :

    ```
            {{ render(controller('wemea_sylius_menu.controller.render_menu::renderAction', {
                   'code': '',
                    'template': '@App/your/menu/template.html.twig'
            })) }}
    ```
3. Add behat test to check menu integration

    You can view full integration on [this file](./tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_your_store.html.twig) and test on [this folder](features/shop)

### Change default resource route mapping

[](#change-default-resource-route-mapping)

If you change defaults routes of application, you need to change route mapping of link resources. You can do it on `config/packages/wemea_sylius_menu.yml` with this configuration :

```
## Default configuration
wemea_sylius_menu:
  resource_path_resolver_configuration:

    custom:
      # route is null for custom type because is not use the router resolver
      route: null
      parameters: []

    product:
      route: 'sylius_shop_product_show'
      parameters:
        slug: 'getSlug'

    taxon:
      route: 'sylius_shop_product_index'
      parameters:
        slug: 'getSlug'
```

Parameters node is an associative array between route parameter and the method name to access at the resource property

### Add new link type to another resource

[](#add-new-link-type-to-another-resource)

This plugin allows creating new resource link. You may need it to redirect on custom resource (like brand, we use this example for instruction example)

1. Override the default MenuLink entity:

    ```
