diff --git a/uc_attribute/uc_attribute.module b/uc_attribute/uc_attribute.module index 94e8311..ef7de97 100644 --- a/uc_attribute/uc_attribute.module +++ b/uc_attribute/uc_attribute.module @@ -11,6 +11,15 @@ * instead of listing each combination separately. */ +/** + * Implementation of hook_views_api(). + */ +function uc_attribute_views_api() { + return array( + 'api' => '2.0', + 'path' => drupal_get_path('module', 'uc_attribute') .'/views', + ); +} /** * Implements hook_help(). diff --git a/uc_attribute/views/uc_attribute.views.inc b/uc_attribute/views/uc_attribute.views.inc new file mode 100644 index 0000000..2969687 --- /dev/null +++ b/uc_attribute/views/uc_attribute.views.inc @@ -0,0 +1,55 @@ +aid); + $option = uc_attribute_option_load($row->oid); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['table']['group'] = t('Product attributes'); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['table']['join']['node'] = array( + 'table' => 'uc_product_options', + 'left_field' => 'nid', + 'field' => 'nid', + 'extra' => array( + array( + 'field' => 'oid', + 'value' => $row->oid, + ), + ), + ); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['table']['group'] = t('Product attributes'); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['price'] = array( + 'title' => t('Price for !aid/!oid', array('!aid' => $4attr->label ? $attr->label : $attr->name, '!oid' => $option->name)), + 'help' => 'Price of the product with the selected option.', + 'field' => array( + 'handler' => 'uc_product_handler_field_price', + ), + ); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['cost'] = array( + 'title' => t('Cost for !aid/!oid', array('!aid' => $attr->label ? $attr->label : $attr->name, '!oid' => $option->name)), + 'help' => 'Cost of the product with the selected option.', + 'field' => array( + 'handler' => 'uc_product_handler_field_price', + ), + ); + $data['uc_product_options_' . $row->aid . '_' . $row->oid]['weight'] = array( + 'title' => t('Weight for !aid/!oid', array('!aid' => $attr->label ? $attr->label : $attr->name, '!oid' => $option->name)), + 'help' => 'Weight of the product with the selected option.', + 'field' => array( + 'handler' => 'uc_product_handler_field_weight', + ), + ); + } + + return $data; +}