1
Answers
Vote up!
0
Vote down!

Can't display random products

To create the problem:

  1. Create a View of Product Displays
  2. Choose to show just the image
  3. Select 'Global: Random' as the Sort Criterion

The result:

  • Preview doesn't change
  • Overlay error message:

    An AJAX HTTP error occurred.
    HTTP Result Code: 500
    Debugging information follows.
    Path: /drupal7/admin/structure/views/view/random_products_for_home_page/preview/page_1/ajax
    StatusText: Internal Server Error
    ResponseText:

Turning On/Off 'Use AJAX' under Advanced makes no difference.
Adding the 'Indexed Node: Node ID' field to give it something easy to randomize doesn't help.
Removing the image field doesn't help.

Is this a bug, or have I done something wrong?

Asked by: AlanQ
on May 15, 2013

1 Answer

Vote up!
1
Vote down!

I believe the problem is that a "View of Product Displays" is using the Search API and it doesn't support the Global Random sort type.

If random products is a must-have feature, I would look into creating a "Content" view and then add the different "Product Display" content types as filters. Then you could add a "Product" relationship to grab the referenced product fields. Finally, to avoid duplicate results, you could set "Use aggregation" to "yes" on "Advanced -> Other" section of views.

Random products could impact performance depending on your situation.

Answer by: Favio Manriquez
Posted: May 15, 2013

Comments

Thank you, favrik, your solution works!

> I believe the problem is that a "View of Product Displays" is using the Search API ...
I wasn't aware of that.

> Finally, to avoid duplicate results, you could set "Use aggregation" to "yes" on "Advanced -> Other" section of views.
Hmm... Don't understand this. And, setting aggregation to 'yes' throws up a SQL error.

- AlanQ on May 20, 2013