Important

You are browsing upcoming documentation for version 5.1 of OroCommerce, OroCRM, and OroPlatform, scheduled for release in March 2023. Read version 5.0 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Available in OroCommerce

Storefront Routes

Storefront API has an API resource routes that returns the information about the storefront URLs. This information includes a resource type and the relative URL of an API resource that you can use to get the data.

Two types of resolvers are used to provide this information:

The resource type resolvers should be registered in the service container with a tag oro_frontend.api.resource_type_resolver, and optionally, the routeName tag attribute can be used to specify the route for which the resolver is applicable.

The API URL resolvers should be registered in the service container with a tag oro_frontend.api.resource_api_url_resolver, and optionally, the routeName tag attribute can be used to specify the route for which the resolver is applicable.

An example of resolvers registration in the services_api.yml file:

services:
    oro_cms.api.resource_type_resolver.landing_page:
        class: Oro\Bundle\FrontendBundle\Api\ResourceTypeResolver
        arguments:
            - 'landing_page' # the resource type should be returned for the route oro_cms_frontend_page_view
        tags:
            - { name: oro_frontend.api.resource_type_resolver, routeName: oro_cms_frontend_page_view }

    oro_cms.api.resource_api_url_resolver.landing_page:
        class: Oro\Bundle\FrontendBundle\Api\ResourceRestApiGetActionUrlResolver
        arguments:
            - '@router'
            - '@oro_api.rest.routes_registry'
            - '@oro_api.value_normalizer'
            - Oro\Bundle\CMSBundle\Entity\Page
        tags:
            - { name: oro_frontend.api.resource_api_url_resolver, routeName: oro_cms_frontend_page_view, requestType: rest }

Here are some useful implementations of ResourceTypeResolverInterface and ResourceApiUrlResolverInterface: