Greetings,

I have created a view type using Product Display index generated by Commerce Search API. By default the format is rendered and image and everything is else displayed OK. However, I need to use fields. So I added a relationship field_product and i am then able to get the data for all fields from the product entity bundle except images and price. I have tested this on multiple installations and the same issue occurs. Any help would be appreciated. I will also post this at Commerce Search API. Thanks Kevin

CommentFileSizeAuthor
#6 view-preview.png204.59 KBpyxio
#6 view-config.png132.57 KBpyxio

Comments

mengi’s picture

In your search index, you will have to go to the fields tab and at the bottom click on 'Add related fields'. You will have to add your product reference field first, save, then go back down to 'Add related fields' and add the price field. You should be able to add the price field now. Don't forget to reindex.

As for images, take a look at https://drupal.org/node/1109318. As far as I can tell there isn't a way for the search API to display images through a view. Perhaps with a HTML rewrite?

pyxio’s picture

Thanks for the reply mengi,

Of course I did all of this and it does not work. However, if you check out the Commerce Kickstart distro it works perfectly. You can get images and price as fields. I don't get why this does not work outside of Kickstart though. Perhaps that can help troubleshoot where the problem might be? Cheers Kevin

mengi’s picture

I meant that there isn't a way to display images using with fields. The only way I know how is to show 'Rendered entity' instead of fields, which is what kickstart uses.

pyxio’s picture

Yes. but in Kickstart if you switch from rendered entity to fields the image field does work if the field_product relationship is configured. My problem is I don't want to use Kickstart and it does not work using the standalone Drupal commerce and search modules. Cheers Kevin

mengi’s picture

Kickstart uses a field called 'rendered node' which shows a view mode (same as showing rendered entity).

pyxio’s picture

StatusFileSize
new132.57 KB
new204.59 KB

Hello,

Here are two screenshots. One shows the view configuration with a image field... not rendered node here. Just the product images. The next screenshot is the view preview which displays the image without any problem. So clearly you display image fields with Search API indexed nodes. The problem is, why does this only work on Commerce Kickstart? Cheers Kevin

mengi’s picture

You are using the 'Collection products' view right? I set up the view exactly as you have it and the images didn't show up for me, so I am not sure what you did different to get them to show up. Hopefully someone with more experience with Kickstart can chime in.

pyxio’s picture

Hi.. it works for me on both a local version of kickstart and a version on pantheon. So I am completely perplexed by this. Yeah, hopefully somebody can help make some sense of this.

drunken monkey’s picture

Issue tags: -views, -Search API

Sorry, I'm not using Drupal Commerce so I can't really help you there.
But please read and follow the issue tag guidelines.

pyxio’s picture

Let's forget about Drupal Commerce for a moment. Why is that search API will index image fields and display fine as a rendered node in a view... but not as a field? What is the reason for this? It seems to me if images appear in a rendered node they should also appear as a field. My preferred approach to theming is rewriting views fields... OK, I get this is apparently not possible for a search api indexed node... but my question remains why? i just need to understand from a technical perspective why a rendered node shows an image but a field does not. I will look into a different method for theming my product display due to this, but I am just curious because it just doesn't seem to make sense to me. Either search api indexes images or it doesn't. but we know it does. so why are they not available in as a field? thanks. Kevin

drunken monkey’s picture

The indexing/searching processes and the Views display/rendering processes are actually more or less completely separate. Something being indexed doesn't really mean that it will display fine in Views.
Also, in a quick test this works perfectly fine for me: I just add the image field as a field in Views and it's there, with all the Field API formatter options normally associated with it. So I can't really say what goes wrong in your case.

pyxio’s picture

This appears to be solved by ensuring that you are using entity module https://drupal.org/project/entity version 7.x-1.5. Please see this thread https://drupal.org/node/2190977 for more info and a big thanks to Ichang https://drupal.org/user/2519980 for his support in this critical issue. Good luck!!

pyxio’s picture

Status: Active » Closed (works as designed)