When adding an image field to a view using a search API index, an image field will always show all of the items even though it has been set to display only one image in the 'Multiple field settings'. I tested some other options in the 'multiple field settings', here is a list of what doesn't work:

  • Display all values in the same row
  • All check boxes/options at the bottom

This functionality works as expected in a view of 'Content'. Not sure which module could be causing this, so any help would be appreciated.

CommentFileSizeAuthor
#8 entity_views_multiple_fields_options.patch1.51 KBfago
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MrGeneric’s picture

Whilst trying to trace the problem I found if I commented out the following line:

public function get_value($values, $field = NULL) {
    if (!$this->entity) {
      return NULL;
    }
    if ($field == 'entity') {
     // return $this->entity;
    }
    
    return parent::get_value($values, $field);
  }

in.../modules/entity/views/handlers/entity_views_handler_field_field.inc, then the problem resolved itself. Maybe this help to trace the problem.

drunken monkey’s picture

Please wait for #1231512: Use real Relationships instead of level magic in Views integration (which will completely re-vamp the display part of the Views integration, and will probably be committed on Monday) and see if the problem still occurs then.

MrGeneric’s picture

OK. I should point out that i was using patch 47 from that thread when this issue occurred. Thanks for all your hard work, It is a really nice improvement.

drunken monkey’s picture

Ah, yes, of course. It has been committed now (with slight changes) so please just use HEAD now.
The bug is in the Entity API part of the code, so please move this issue there or re-open #1266036: Add generic Views entity tables with fields and relationships.

MrGeneric’s picture

Project: Search API » Entity API

Just had a chance to upgrade to latest entity/ search api dev releases and can confirm this is still an issue. Moving to Entity API as requested.

jaymallison’s picture

subscribed.

modstore’s picture

I am also having this same problem.

fago’s picture

Status: Active » Needs review
FileSize
1.51 KB

Attached patch should fix it, please test.

jaymallison’s picture

#8 works for me. I assume the forced "Display all values in the same row" was intentional due to other limitations in Entity API? Either way it's nbd for me. This now works for me as I need it to.

Thank you for the patch, I can remove my hack I had to do to get around this.

fago’s picture

Status: Needs review » Fixed

thanks for testing, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

magtak’s picture

Status: Closed (fixed) » Active

Still experiencing this problem with latest (today's) dev version of Entity API and Search API. Do I need to apply the older #8 patch nonetheless?

magtak’s picture

Just checked manually, the patch is applied, the problems still persists though. Using CSS to hide the additional data for the time being

kasalla’s picture

#8 thanks, works great for me!

D7, Ubercart 3.dev, Search API

MickC’s picture

Issue summary: View changes

Problem persists with 7.x-1,5 even though this patch is committed.

Images from a referenced entity can be added as related fields, firstly as referenced-entity: image "the file", then as image fields related to that.
So I can get the URL as described here, and option @2 works but only if there is a single value in the field.
Views is not providing the Multiple Values option, so multiple values appear as a string of URLs in which case the image does not appear.

Would appreciate some help to be able to do either of these things:
a) force views to treat as a multiple value field
b) force Search API to only index the first value

drunken monkey’s picture

b) force Search API to only index the first value

This can be done with the "Aggregated fields" data alteration, and its aggregation type "First".
However, the displayed entities usually don't reflect the indexed data, this is only the case when using Solr and checking "Return results data from Solr" (or similar) in the server options.

NWOM’s picture

@drunken monkey: Is there a way currently to aggregate by "Last" instead of "First"?

drunken monkey’s picture

@drunken monkey: Is there a way currently to aggregate by "Last" instead of "First"?

No, but it should be simple to add this yourself – either by directly modifying the existing data alteration or by copying the code to create a new, custom one.