2

I created model AcmeBundle\Api\Model\AcmeLineItem with attributes product and productUnit. Then I added a new processor which sets in the result collection of the model items and register it with tag:

- { name: oro.api.processor, action: get_list, group: load_data, requestType: frontend, class: AcmeBundle\Api\Model\AcmeLineItem, priority: 55 }

Model configuration in the api_frontend.yml:

AcmeBundle\Api\Model\AcmeLineItem:
    fields:
        quantity:
            data_type: string
        productSku:
            data_type: string
        product:
            target_class: Oro\Bundle\ProductBundle\Entity\Product
            target_type: to-one
            property_path: product
        productUnit:
            target_class: Oro\Bundle\ProductBundle\Entity\ProductUnit
            target_type: to-one
    actions:
        get: false
        get_list:
            description: Get bought line items
            disable_sorting: true
        update: false
        delete: false
        delete_list: false
        create: false

The simple requests work fine, but with the include parameter an issue occurred. With value productUnit related items visible in response, but for product in value - an exception in response, with 500 code and [Semantical Error] line 0, col -1 near 'SELECT r FROM': Error: Cannot select entity through identification variables without choosing at least one root entity alias. message.

With debugging, I found that exception occurred during the normalization of the varianProducts attribute of product entity via @oro_api.object_normalizer. I didnt found a similar exception for the included products on shippinglistitems` API methods, seams like it use a different normalizer from the product entity.

4

0 回答 0