0

I am using Drupal commerce, context and search api module in Drupal 7 website. I have created views to display all products, which is working fine.

Now, I have added contextual filter product category in views to filter the product according to category and it also working fine.

I have also added block display in views and display block in left side region using context module. Its showing the block in Left side bar but its not filtering product in block according to contextual filter.

Please suggest me.

Export code of the views:

$view = new view();
$view->name = 'product_list';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_product_index';
$view->human_name = 'Product List';
$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'] = 'Product List';
$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'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* 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_index';
$handler->display->display_options['relationships']['field_product']['field'] = 'field_product';
/* Field: Indexed Node: Node ID */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'search_api_index_product_index';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Field: Product: Title (indexed) */
$handler->display->display_options['fields']['field_product_title']['id'] = 'field_product_title';
$handler->display->display_options['fields']['field_product_title']['table'] = 'search_api_index_product_index';
$handler->display->display_options['fields']['field_product_title']['field'] = 'field_product_title';
$handler->display->display_options['fields']['field_product_title']['label'] = '';
$handler->display->display_options['fields']['field_product_title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_product_title']['link_to_entity'] = 0;
/* Field: Product » Price: Amount (decimal) (indexed) */
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['id'] = 'field_product_commerce_price_amount_decimal';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['table'] = 'search_api_index_product_index';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['field'] = 'field_product_commerce_price_amount_decimal';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['label'] = '';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['precision'] = '0';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['prefix'] = '$';
$handler->display->display_options['fields']['field_product_commerce_price_amount_decimal']['link_to_entity'] = 0;
/* Field: Commerce Product: Image */
$handler->display->display_options['fields']['field_product_image']['id'] = 'field_product_image';
$handler->display->display_options['fields']['field_product_image']['table'] = 'entity_commerce_product';
$handler->display->display_options['fields']['field_product_image']['field'] = 'field_product_image';
$handler->display->display_options['fields']['field_product_image']['relationship'] = 'field_product';
$handler->display->display_options['fields']['field_product_image']['label'] = '';
$handler->display->display_options['fields']['field_product_image']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_product_image']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_product_image']['settings'] = array(
  'image_style' => 'medium',
  'image_link' => '',
);
$handler->display->display_options['fields']['field_product_image']['delta_limit'] = '1';
$handler->display->display_options['fields']['field_product_image']['delta_offset'] = '0';
/* Field: Commerce Product: Add to Cart form */
$handler->display->display_options['fields']['add_to_cart_form']['id'] = 'add_to_cart_form';
$handler->display->display_options['fields']['add_to_cart_form']['table'] = 'views_entity_commerce_product';
$handler->display->display_options['fields']['add_to_cart_form']['field'] = 'add_to_cart_form';
$handler->display->display_options['fields']['add_to_cart_form']['relationship'] = 'field_product';
$handler->display->display_options['fields']['add_to_cart_form']['label'] = '';
$handler->display->display_options['fields']['add_to_cart_form']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['add_to_cart_form']['show_quantity'] = 0;
$handler->display->display_options['fields']['add_to_cart_form']['default_quantity'] = '1';
$handler->display->display_options['fields']['add_to_cart_form']['combine'] = 1;
$handler->display->display_options['fields']['add_to_cart_form']['display_path'] = 0;
$handler->display->display_options['fields']['add_to_cart_form']['line_item_type'] = 0;
/* Contextual filter: Indexed Node: Category */
$handler->display->display_options['arguments']['field_category']['id'] = 'field_category';
$handler->display->display_options['arguments']['field_category']['table'] = 'search_api_index_product_index';
$handler->display->display_options['arguments']['field_category']['field'] = 'field_category';
$handler->display->display_options['arguments']['field_category']['default_argument_type'] = 'taxonomy_tid';
$handler->display->display_options['arguments']['field_category']['default_argument_options']['node'] = TRUE;
$handler->display->display_options['arguments']['field_category']['default_argument_options']['limit'] = TRUE;
$handler->display->display_options['arguments']['field_category']['default_argument_options']['vocabularies'] = array(
  'product_category' => 'product_category',
);
$handler->display->display_options['arguments']['field_category']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_category']['break_phrase'] = 0;
$handler->display->display_options['arguments']['field_category']['not'] = 0;
/* Filter criterion: Indexed Node: Sites */
$handler->display->display_options['filters']['field_sites']['id'] = 'field_sites';
$handler->display->display_options['filters']['field_sites']['table'] = 'search_api_index_product_index';
$handler->display->display_options['filters']['field_sites']['field'] = 'field_sites';
$handler->display->display_options['filters']['field_sites']['value'] = array(
  'flexstone' => 'flexstone',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'flexstone/product-list';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Product: Title (indexed) */
$handler->display->display_options['fields']['field_product_title']['id'] = 'field_product_title';
$handler->display->display_options['fields']['field_product_title']['table'] = 'search_api_index_product_index';
$handler->display->display_options['fields']['field_product_title']['field'] = 'field_product_title';
$handler->display->display_options['fields']['field_product_title']['label'] = '';
$handler->display->display_options['fields']['field_product_title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_product_title']['link_to_entity'] = 0;
  • have you added the default context from url settings? – Mohammed Shameem Oct 26 '13 at 5:16
  • @MohammedShameem, you mean 'When the filter value is NOT in the URL' setting in views. If there is no arguments, I want to display all product and I have configure this in same manner. – Jayendra Kainthola Oct 26 '13 at 5:19
  • @MohammedShameem, Page display of the views is displaying correct result whether there is arguments or not in url, but product are not filtered in block. – Jayendra Kainthola Oct 26 '13 at 5:21
  • You need to set that to get value from url have you done that? – Mohammed Shameem Oct 26 '13 at 5:34
  • @MohammedShameem, yes, want to filter product in block using contextual filter. – Jayendra Kainthola Oct 26 '13 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.