4

I am beginner in sylius and i would like use api-platform for my shop instead of shop-api for sylius. Is there any simple way to do that ?

This is my api-platform configuration in sylius

api_platform:
mapping:
    paths:
        - '%kernel.project_dir%/config/api_platform/resources' # yaml or xml directory configuration     

This is the route prefix configuration

api_platform:
  resource: .
  type: api_platform
  prefix: /shop-api/

This is my product routing configuration

resources:
  App\Entity\Product\Product:
    routePrefix: '/product'
    attributes:
        route_prefix: '/product'
        normalization_context:
            groups: ['Default']
        denormalization_context:
            api_allow_update: true
            groups: ['Default']

This is the default serialization of sylis product

Sylius\Component\Product\Model\Product:
exclusion_policy: ALL
xml_root_name: product
properties:
    id:
        expose: true
        type: integer
        xml_attribute: true
        groups: [Default, Detailed, Autocomplete]
    code:
        expose: true
        type: string
        groups: [Default, Detailed, Autocomplete]
    options:
        expose: true
        type: array
        groups: [Default, Detailed]
    attributes:
        expose: true
        type: array
        groups: [Detailed]
    associations:
        expose: true
        type: array
        groups: [Detailed]
    translations:
        expose: true
        type: array
        groups: [Detailed]
virtual_properties:
    getName:
        serialized_name: name
        groups: [Default, Detailed, Autocomplete]

When i make this api request

curl -X GET "http://127.0.0.1:8000/shop-api/product/products" -H "accept: application/json"

this is result

[
 [],
 [],
 [],
 [],
]

I think i have missed something. Thank you for help

Daniel
  • 49
  • 4

0 Answers0