sylius_admin_ajax_generate_product_slug:
    path: /generate-slug/
    methods: [GET]
    defaults:
        _controller: sylius.controller.product_slug::generateAction
        _format: json

sylius_admin_ajax_product_by_name_phrase:
    path: /search
    methods: [GET]
    defaults:
        _controller: sylius.controller.product::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findByNamePart
                arguments:
                    phrase: $phrase
                    locale: expr:service('sylius.context.locale').getLocaleCode()
                    limit: "!!int %sylius.ajax.product.autocomplete_limit%"

sylius_admin_ajax_products_by_phrase:
    path: /search-phrase
    methods: [GET]
    defaults:
        _controller: sylius.controller.product::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findByPhrase
                arguments:
                    phrase: $phrase
                    locale: expr:service('sylius.context.locale').getLocaleCode()
                    limit: "!!int %sylius.ajax.product.autocomplete_limit%"

sylius_admin_ajax_product_by_code:
    path: /code
    methods: [GET]
    defaults:
        _controller: sylius.controller.product::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findBy
                arguments: [code: $code]

sylius_admin_ajax_product_index:
    path: /
    methods: [GET]
    defaults:
        _controller: sylius.controller.product::indexAction
        _format: json
        _sylius:
            serialization_groups: [Default]
            permission: true
            grid: sylius_admin_product
