OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Searching on Related Entities

This topic contains 4 replies, has 2 voices, and was last updated by  archy_bold 8 years, 1 month ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34094

    archy_bold
    Participant

    Hi there. I’m trying to create a select/create inline form type for contact addresses and I’ve mostly had some good success with it. However, I need the search to limit the results it gets on addresses for a particular contact. The issue I have it that no matter what I do, I can’t seem to get the information for the contact into the search index.

    So here’s my search.yml:

    My definition for the search handler:

    With owner.id in the property definition, I get an error:

    PropertyAccessor requires a graph of objects or arrays to operate on, but it found type “NULL” while trying to traverse path “owner.id” at property “id”.

    And without that column, I see an empty owner object:

    Then in the search handler, I try to get the results as follows:

    I’m having no issues getting the contact ID from the form type to the search handler, the problem seems to be that the information I’m trying to limit on isn’t in the search index itself. Can anyone explain what I’m doing wrong?

    Thanks,
    Simon

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #34095

    Yevhen Shyshkin
    Participant

    Hello.

    1) PropertyAccessor requires a graph of objects or arrays to operate on, but it found type “NULL” while trying to traverse path “owner.id” at property “id”.
    Please, check if your contact address has an owner – if not then this is invalid address, address always must have related contact.

    2) And without that column, I see an empty owner object:
    It’s not empty, it’s just not initialized proxy object. In general this is not really good idea to pass serialized object to frontend (unless you serialized them manually in search hander) – usually better to get field values via property paths (like owner.id).

    3) $query->andWhere(‘owner.id’, ‘=’, $contactId, ‘integer’);
    This is a query to search index, not regular DB, so you should use fields defined in search index. In this case you should use “ownerId” instead of “owner.id”. To make you life easier you can always look at real index values (e.g. ownerId might be stored in DB table oro_search_index_integer).

    #34096

    archy_bold
    Participant

    Thanks for the response Yevhen, that’s really helped.

    Re your responses:

    1) There is one address without an owner, would this break it for all the results?

    2) Thanks, I understand now.

    3) I tried ownerId but to no avail. I just tried it now and it worked! Maybe it hadn’t indexed properly, but I wasn’t aware of the search tables, so that will help for debugging.

    #34097

    Yevhen Shyshkin
    Participant

    > There is one address without an owner, would this break it for all the results?
    Well, even one address without owner is invalid. Despite that, you’ll probably never receive it because you are filtering by owner and it means that owner exists. Still, you can override that method in your handler and catch these exceptions.

    #34098

    archy_bold
    Participant

    It’s not really a problem as long as I don’t pass the related info to the search handler. Cool, cheers for the info.

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top