2

I'm using Drupal 7 on my site with Ubercart 7.x - 3.4. I want is an existing module or a view customization tips to make the most selling / best selling product.

3

Here is a view Export

$view = new view;
$view->name = 'best_sellers';
$view->description = 'Best Sellers';
$view->tag = 'Best Sellers';
$view->base_table = 'node';
$view->human_name = 'Best Sellers';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$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'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Fields: uc_product_image */
$handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
$handler->display->display_options['fields']['entity_id']['table'] = 'field_data_uc_product_image';
$handler->display->display_options['fields']['entity_id']['field'] = 'entity_id';
$handler->display->display_options['fields']['entity_id']['label'] = '';
$handler->display->display_options['fields']['entity_id']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['trim'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['entity_id']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['entity_id']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['entity_id']['alter']['html'] = 0;
$handler->display->display_options['fields']['entity_id']['element_label_colon'] = 1;
$handler->display->display_options['fields']['entity_id']['element_default_classes'] = 1;
$handler->display->display_options['fields']['entity_id']['hide_empty'] = 0;
$handler->display->display_options['fields']['entity_id']['empty_zero'] = 0;
$handler->display->display_options['fields']['entity_id']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['entity_id']['settings'] = array(
  'image_style' => 'thumbnail',
  'image_link' => 'content',
);
/* Field: Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Product: Buy it now button */
$handler->display->display_options['fields']['buyitnowbutton']['id'] = 'buyitnowbutton';
$handler->display->display_options['fields']['buyitnowbutton']['table'] = 'uc_products';
$handler->display->display_options['fields']['buyitnowbutton']['field'] = 'buyitnowbutton';
$handler->display->display_options['fields']['buyitnowbutton']['label'] = '';
$handler->display->display_options['fields']['buyitnowbutton']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['trim'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['alter']['html'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['element_label_colon'] = 1;
$handler->display->display_options['fields']['buyitnowbutton']['element_default_classes'] = 1;
$handler->display->display_options['fields']['buyitnowbutton']['hide_empty'] = 0;
$handler->display->display_options['fields']['buyitnowbutton']['empty_zero'] = 0;
/* Field: Product: Sell price */
$handler->display->display_options['fields']['sell_price']['id'] = 'sell_price';
$handler->display->display_options['fields']['sell_price']['table'] = 'uc_products';
$handler->display->display_options['fields']['sell_price']['field'] = 'sell_price';
$handler->display->display_options['fields']['sell_price']['label'] = '';
$handler->display->display_options['fields']['sell_price']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['sell_price']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['sell_price']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['sell_price']['alter']['trim'] = 0;
$handler->display->display_options['fields']['sell_price']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['sell_price']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['sell_price']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['sell_price']['alter']['html'] = 0;
$handler->display->display_options['fields']['sell_price']['element_label_colon'] = 1;
$handler->display->display_options['fields']['sell_price']['element_default_classes'] = 1;
$handler->display->display_options['fields']['sell_price']['hide_empty'] = 0;
$handler->display->display_options['fields']['sell_price']['empty_zero'] = 0;
$handler->display->display_options['fields']['sell_price']['set_precision'] = 0;
$handler->display->display_options['fields']['sell_price']['precision'] = '0';
$handler->display->display_options['fields']['sell_price']['format_plural'] = 0;
/* Sort criterion: Order product: Qty */
$handler->display->display_options['sorts']['qty']['id'] = 'qty';
$handler->display->display_options['sorts']['qty']['table'] = 'uc_order_products';
$handler->display->display_options['sorts']['qty']['field'] = 'qty';
$handler->display->display_options['sorts']['qty']['order'] = 'DESC';
/* Filter: Node: Is a product */
$handler->display->display_options['filters']['is_product']['id'] = 'is_product';
$handler->display->display_options['filters']['is_product']['table'] = 'uc_products';
$handler->display->display_options['filters']['is_product']['field'] = 'is_product';
$handler->display->display_options['filters']['is_product']['value'] = '1';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'best_sellers');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Best Sellers';
$handler->display->display_options['defaults']['css_class'] = FALSE;
$handler->display->display_options['css_class'] = 'new-product-block';
$handler->display->display_options['block_description'] = 'Best Sellers';
$translatables['best_sellers'] = array(
  t('Defaults'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort By'),
  t('Asc'),
  t('Desc'),
  t('.'),
  t(','),
  t('Block'),
  t('Best Sellers'),
);

How to

  1. Login to Drupal as an administrator. Go to Structure > Views.

  2. Click “Import View from Code”

Add "Popular Products" view

  • wow! worked like never did before – Dewsworld Mar 24 '13 at 14:57
  • My pleasure ... :) – niksmac Mar 24 '13 at 15:15
  • If I import this code, what is the next step, will it create a new view ? – Bala Sep 6 '13 at 4:33
  • @Bala yes it will – niksmac Sep 10 '13 at 4:02
  • Disclaimer: This view does not show 'Most Popular' or 'Best Selling' products. It has sort on 'qty' in 'uc_order_products' table. This sort doesn't import because it's a 'node' view and 'uc_order_products' is part of the 'Order Products' bundle. Even if this sort was a part of the view, it wouldn't show most popular products because that data is per product per order, not per product overall. The reason a 'Best Sellers' view doesn't exist is because it's actually very hard to track this statistic through views (not easy with custom code either). – leexonline Dec 20 '13 at 1:29
0

easyrec for ubercart integrates the product recommender functionality of easyrec (http://easyrec.org/) into an ubercart shop. It provides Drupal Blocks for the display of recommendations or product rankings. Also you can integrate with views 3.

Available Blocks

  • easyrec: other users also bought
  • easyrec: other users also viewed
  • easyrec: recommendations for user
  • easyrec: most bought items
  • easyrec: most viewed items

The Blocks are fully style-able using the module administration interface. Or can use one of the following drawing callbacks:

  • Views 3 support
  • Jquery Carousel
  • Image List
  • Text List
  • create your own using javascript or the drupal hook

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.