You are here

function uc_product_views_tables in Ubercart 5

Implementation of hook_views_tables()

See also

uc_views_handler_price

uc_views_handler_weight

uc_product_views_handler_add_to_cart_link

uc_product_views_handler_filter_product

File

uc_product/uc_product.module, line 1040
The product module for Ubercart.

Code

function uc_product_views_tables() {
  $tables['uc_products'] = array(
    'name' => 'uc_products',
    'join' => array(
      'left' => array(
        'table' => 'node',
        'field' => 'vid',
      ),
      'right' => array(
        'field' => 'vid',
      ),
    ),
    'fields' => array(
      'model' => array(
        'name' => t('Product: SKU'),
        'help' => t('Model number'),
        'handler' => 'views_handler_field_nodelink',
        'option' => array(
          '#type' => 'select',
          '#options' => array(
            'link' => 'As link',
            'nolink' => 'Without link',
          ),
        ),
        'sortable' => TRUE,
      ),
      'list_price' => array(
        'name' => t('Product: List price'),
        'help' => t("Manufacturer's suggested price"),
        'handler' => 'uc_views_handler_price',
        'sortable' => TRUE,
      ),
      'cost' => array(
        'name' => t('Product: Cost'),
        'help' => t('Amount to buy the unit'),
        'handler' => 'uc_views_handler_price',
        'sortable' => TRUE,
      ),
      'sell_price' => array(
        'name' => t('Product: Sell price'),
        'help' => t('Amount to sell the unit'),
        'handler' => 'uc_views_handler_price',
        'sortable' => TRUE,
      ),
      'weight' => array(
        'name' => t('Product: Weight'),
        'help' => t('Physical weight'),
        'handler' => 'uc_views_handler_weight',
        'sortable' => TRUE,
      ),
      'addtocartlink' => array(
        'name' => t('Product: Add to cart link'),
        'help' => t("Form to put the product in the customer's cart."),
        'sortable' => FALSE,
        'notafield' => TRUE,
        'handler' => 'uc_product_views_handler_add_to_cart_link',
      ),
      'buyitnowbutton' => array(
        'name' => t('Product: Buy it now button'),
        'help' => t('A button to add a product to the cart without quantity or attribute fields.'),
        'sortable' => FALSE,
        'notafield' => TRUE,
        'handler' => 'uc_product_views_handler_buy_it_now_button',
      ),
    ),
    'sorts' => array(
      'model' => array(
        'name' => t('Product: SKU'),
      ),
      'list_price' => array(
        'name' => t('Product: List price'),
      ),
      'cost' => array(
        'name' => t('Product: Cost'),
      ),
      'sell_price' => array(
        'name' => t('Product: Sell price'),
      ),
      'weight' => array(
        'name' => t('Product: Weight'),
      ),
      'ordering' => array(
        'name' => t('Product: List Order'),
      ),
    ),
    'filters' => array(
      'is_product' => array(
        'name' => t('Product: Is a product'),
        'operator' => array(
          '=' => 'Equals',
        ),
        'list' => 'views_handler_operator_yesno',
        'list-type' => 'select',
        'handler' => 'uc_product_views_handler_filter_product',
        'help' => t('Filter the node based on whether or not it is derived from content type Product.'),
      ),
      'model' => array(
        'name' => t('Product: SKU'),
        'operator' => 'views_handler_operator_like',
        'handler' => 'views_handler_filter_like',
        'help' => t('This filter allows nodes to be filtered by their model number.'),
      ),
      'list_price' => array(
        'name' => t('Product: List Price'),
        'operator' => array(
          '=' => 'Equals',
          '<' => 'Less Than',
          '>' => 'Greater Than',
        ),
        'handler' => 'views_handler_filter_numeric',
        'help' => t('Filter the node based on whether or not it matches list price criteria.'),
      ),
      'cost' => array(
        'name' => t('Product: Cost'),
        'operator' => array(
          '=' => 'Equals',
          '<' => 'Less Than',
          '>' => 'Greater Than',
        ),
        'handler' => 'views_handler_filter_numeric',
        'help' => t('Filter the node based on whether or not it matches cost criteria.'),
      ),
      'sell_price' => array(
        'name' => t('Product: Sell Price'),
        'operator' => array(
          '=' => 'Equals',
          '<' => 'Less Than',
          '>' => 'Greater Than',
        ),
        'handler' => 'views_handler_filter_numeric',
        'help' => t('Filter the node based on whether or not it matches sell price criteria.'),
      ),
      'weight' => array(
        'name' => t('Product: Weight'),
        'operator' => array(
          '=' => 'Equals',
          '<' => 'Less Than',
          '>' => 'Greater Than',
        ),
        'handler' => 'views_handler_filter_numeric',
        'help' => t('Filter the node based on whether or not it matches weight criteria.'),
      ),
    ),
  );
  return $tables;
}