I found that issue when creating a product collection page with views. A special kind of products are shown e.g. based on taxonomy. When creating a sort function "random" the page crashes. If i use sort by name or something else it works!

Here is my view:

$view = new view();
$view->name = 'display_products_by_taxonomy';
$view->description = 'Display all the products that are available, using Search API';
$view->tag = 'default';
$view->base_table = 'search_api_index_product_display';
$view->human_name = 'Display Products by Taxonomy';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = '%1';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'product-list four columns mobile-four';
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
  'field_images' => 'field_images',
  'title' => 'title',
  'commerce_price' => 'commerce_price',
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'No results found for your search.
  Check your spelling or try another term.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Indexed Node: Product */
$handler->display->display_options['relationships']['field_product']['id'] = 'field_product';
$handler->display->display_options['relationships']['field_product']['table'] = 'search_api_index_product_display';
$handler->display->display_options['relationships']['field_product']['field'] = 'field_product';
/* Field: Commerce Product: field_images */
$handler->display->display_options['fields']['field_images']['id'] = 'field_images';
$handler->display->display_options['fields']['field_images']['table'] = 'entity_commerce_product';
$handler->display->display_options['fields']['field_images']['field'] = 'field_images';
$handler->display->display_options['fields']['field_images']['relationship'] = 'field_product';
$handler->display->display_options['fields']['field_images']['label'] = '';
$handler->display->display_options['fields']['field_images']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_images']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_images']['element_default_classes'] = FALSE;
$handler->display->display_options['fields']['field_images']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_images']['type'] = 'image_delta';
$handler->display->display_options['fields']['field_images']['settings'] = array(
  'deltas' => '0',
  'deltas_reversed' => 0,
  'image_style' => 'product_medium',
  'image_link' => '',
);
$handler->display->display_options['fields']['field_images']['delta_offset'] = '0';
/* Field: Indexed Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'search_api_index_product_display';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['exclude'] = TRUE;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_entity'] = 0;
/* Field: Commerce Product: Price */
$handler->display->display_options['fields']['commerce_price']['id'] = 'commerce_price';
$handler->display->display_options['fields']['commerce_price']['table'] = 'entity_commerce_product';
$handler->display->display_options['fields']['commerce_price']['field'] = 'commerce_price';
$handler->display->display_options['fields']['commerce_price']['relationship'] = 'field_product';
$handler->display->display_options['fields']['commerce_price']['label'] = '';
$handler->display->display_options['fields']['commerce_price']['exclude'] = TRUE;
$handler->display->display_options['fields']['commerce_price']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['commerce_price']['click_sort_column'] = 'amount';
$handler->display->display_options['fields']['commerce_price']['type'] = 'commerce_price_formatted_amount';
$handler->display->display_options['fields']['commerce_price']['settings'] = array(
  'calculation' => '0',
);
/* Field: Indexed Node: URL */
$handler->display->display_options['fields']['url']['id'] = 'url';
$handler->display->display_options['fields']['url']['table'] = 'search_api_index_product_display';
$handler->display->display_options['fields']['url']['field'] = 'url';
$handler->display->display_options['fields']['url']['label'] = '';
$handler->display->display_options['fields']['url']['exclude'] = TRUE;
$handler->display->display_options['fields']['url']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['url']['display_as_link'] = FALSE;
$handler->display->display_options['fields']['url']['link_to_entity'] = 0;
/* Field: Global: Custom text */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = '';
$handler->display->display_options['fields']['nothing']['alter']['text'] = '<a href="[url]">
[field_images]
<span class="product-list-title">[title]</span>
<span class="commerce-product-field-commerce-price left c81">[commerce_price]</span>
</a>';
$handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
/* Sort criterion: Indexed Node: Type */
$handler->display->display_options['sorts']['field_type']['id'] = 'field_type';
$handler->display->display_options['sorts']['field_type']['table'] = 'search_api_index_product_display';
$handler->display->display_options['sorts']['field_type']['field'] = 'field_type';
/* Contextual filter: Indexed Node: Collection */
$handler->display->display_options['arguments']['field_collection']['id'] = 'field_collection';
$handler->display->display_options['arguments']['field_collection']['table'] = 'search_api_index_product_display';
$handler->display->display_options['arguments']['field_collection']['field'] = 'field_collection';
$handler->display->display_options['arguments']['field_collection']['default_action'] = 'not found';
$handler->display->display_options['arguments']['field_collection']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['field_collection']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_collection']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['field_collection']['validate']['type'] = 'taxonomy_term';
$handler->display->display_options['arguments']['field_collection']['validate_options']['vocabularies'] = array(
  'collection' => 'collection',
);
$handler->display->display_options['arguments']['field_collection']['break_phrase'] = 0;
/* Filter criterion: Indexed Node: Item language */
$handler->display->display_options['filters']['search_api_language']['id'] = 'search_api_language';
$handler->display->display_options['filters']['search_api_language']['table'] = 'search_api_index_product_display';
$handler->display->display_options['filters']['search_api_language']['field'] = 'search_api_language';
$handler->display->display_options['filters']['search_api_language']['value'] = array(
  'current' => 'current',
);
/* Filter criterion: Indexed Node: Status */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'search_api_index_product_display';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = array(
  1 => '1',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'taxonomy/term/%';
$handler->display->display_options['menu']['title'] = 'All products';
$handler->display->display_options['menu']['weight'] = '50';
$handler->display->display_options['menu']['name'] = 'main-menu';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['tab_options']['weight'] = '0';
$translatables['display_products_by_taxonomy'] = array(
  t('Master'),
  t('%1'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('No results found for your search.
  Check your spelling or try another term.'),
  t('Product'),
  t('<a href="[url]">
[field_images]
<span class="product-list-title">[title]</span>
<span class="commerce-product-field-commerce-price left c81">[commerce_price]</span>
</a>'),
  t('All'),
  t('Page'),
);

Comments

mglaman’s picture

StatusFileSize
new78.68 KB

I was able to replicate the same error happen as well:

Call to undefined method SearchApiViewsQuery::add_orderby() in /Applications/XAMPP/xamppfiles/htdocs/commerce_kickstart/profiles/commerce_kickstart/modules/contrib/views/handlers/views_handler_sort_random.inc on line 15

vasike’s picture

Project:Drupal Commerce» Commerce Kickstart
Version:7.x-1.7» 7.x-2.x-dev
Component:Product» Miscellaneous
Category:bug» support
Priority:Major» Normal
Status:Active» Postponed (maintainer needs more info)

This seems rather an issue Commerce Kickstart related.

I tried to import the view you provided in a Commerce Kickstart without success:
Sort criterion handler search_api_index_product_display.field_type is not available.

Are there some changes in your Kickstart that we should know about?

jsacksick’s picture

Project:Commerce Kickstart» Search API
Version:7.x-2.x-dev» 7.x-1.x-dev
Status:Postponed (maintainer needs more info)» Closed (duplicate)

That's a known Search API issue, see #1197538: Random sort in Views