Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-22308

SearchService: Filtering on Attributes of Type "Object Relation" does not work

    XMLWordPrintable

    Details

      Description

      When filtering on an attribute of type Object Relation the results are not as expected.

      (as in

      new Criterion\Field( 'recipient', Criterion\Operator::EQ, $currentUserId )
      

      where 'recipient' is an attribute of datatype 'Object Relation')

      This seems to be due to the fact that the searchService only takes into consideration the database fields sort_key_int or sort_key_string (depending onthe datatype).

      But in the converter class for Relation the sortKey is hardcoded to "false" which leads to empty entries in the sort_key_int column of ezcontentobject_attribute table rows for Object Relations.

      My quick fix was to replace

      Relation.php
      public function toFieldValue( StorageFieldValue $value, FieldValue $fieldValue )
          {
              $fieldValue->data = array(
                  "destinationContentId" => $value->dataInt,
              );
              $fieldValue->sortKey = false;
          }
      

      with

      Relation.php
      public function toFieldValue( StorageFieldValue $value, FieldValue $fieldValue )
          {
              $fieldValue->data = array(
                  "destinationContentId" => $value->dataInt,
              );
              $storageFieldValue->sortKeyInt = (int)$value->sortKey;
          }
      

      which seems to fix the problem. Since i'm no kernel-expert on eZ5 i'm not sure if this is the best solution, though.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              reneh Rene Hrdina
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 7 hours, 40 minutes
                  7h 40m