uc_product_kit.views.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks for Ubercart product kits.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function uc_product_kit_views_data() {
  10. $data['uc_product_kits']['table']['group'] = t('Product kit');
  11. // Explain how to link product kit nodes to back to their parents.
  12. $data['node']['table']['join']['uc_product_kits'] = array(
  13. 'left_field' => 'vid',
  14. 'field' => 'vid',
  15. );
  16. $data['uc_products']['table']['join']['uc_product_kits'] = array(
  17. 'left_field' => 'vid',
  18. 'field' => 'vid',
  19. );
  20. // Relate components to their parent kits.
  21. $data['uc_products']['product_kit'] = array(
  22. 'group' => t('Product kit'),
  23. 'relationship' => array(
  24. 'title' => t('Parent'),
  25. 'help' => t('Relate product kit components to their parent kits.'),
  26. 'handler' => 'views_handler_relationship',
  27. 'base' => 'uc_product_kits',
  28. 'base field' => 'product_id',
  29. 'relationship field' => 'nid',
  30. 'label' => t('kit'),
  31. ),
  32. );
  33. // Explain how to link parents back to their components.
  34. $data['uc_product_kit_parents']['table']['join']['node'] = array(
  35. 'left_field' => 'vid',
  36. 'field' => 'vid',
  37. 'table' => 'uc_product_kits',
  38. );
  39. // Relate kits to their components.
  40. $data['uc_products']['product_kit_component'] = array(
  41. 'group' => t('Product kit'),
  42. 'relationship' => array(
  43. 'title' => t('Component'),
  44. 'help' => t('Relate product kits to their components. This relationship will create one record for each component of the kit.'),
  45. 'handler' => 'views_handler_relationship',
  46. 'base' => 'node',
  47. 'base field' => 'nid',
  48. 'relationship table' => 'uc_product_kit_parents',
  49. 'relationship field' => 'product_id',
  50. 'label' => t('component'),
  51. ),
  52. );
  53. $data['uc_product_kits']['mutable'] = array(
  54. 'title' => t('Mutable'),
  55. 'help' => t('A flag indicating whether the contents of the kit can be changed by the customer.'),
  56. 'field' => array(
  57. 'handler' => 'views_handler_field_boolean',
  58. 'click sortable' => TRUE,
  59. ),
  60. 'filter' => array(
  61. 'handler' => 'views_handler_filter_boolean_operator',
  62. 'type' => 'yes-no',
  63. ),
  64. 'sort' => array(
  65. 'handler' => 'views_handler_sort',
  66. ),
  67. );
  68. $data['uc_product_kits']['qty'] = array(
  69. 'title' => t('Quantity'),
  70. 'help' => t('The number of this product contained in the kit.'),
  71. 'field' => array(
  72. 'handler' => 'views_handler_field_numeric',
  73. 'click sortable' => TRUE,
  74. ),
  75. 'filter' => array(
  76. 'handler' => 'views_handler_filter_numeric',
  77. 'allow empty' => TRUE,
  78. ),
  79. 'argument' => array(
  80. 'handler' => 'views_handler_argument_numeric',
  81. ),
  82. 'sort' => array(
  83. 'handler' => 'views_handler_sort',
  84. ),
  85. );
  86. $data['uc_product_kits']['discount'] = array(
  87. 'title' => t('Discount'),
  88. 'help' => t('The adjustment to the {uc_products}.sell_price of the product.'),
  89. 'field' => array(
  90. 'handler' => 'views_handler_field_numeric',
  91. 'click sortable' => TRUE,
  92. ),
  93. 'filter' => array(
  94. 'handler' => 'views_handler_filter_numeric',
  95. 'allow empty' => TRUE,
  96. ),
  97. 'argument' => array(
  98. 'handler' => 'views_handler_argument_numeric',
  99. ),
  100. 'sort' => array(
  101. 'handler' => 'views_handler_sort',
  102. ),
  103. );
  104. $data['uc_product_kits']['ordering'] = array(
  105. 'title' => t('Weight'),
  106. 'help' => ('The weight of this product in relation to other products in the kit.'),
  107. 'field' => array(
  108. 'handler' => 'views_handler_field_numeric',
  109. 'click sortable' => TRUE,
  110. ),
  111. 'filter' => array(
  112. 'handler' => 'views_handler_filter_numeric',
  113. 'allow empty' => TRUE,
  114. ),
  115. 'argument' => array(
  116. 'handler' => 'views_handler_argument_numeric',
  117. ),
  118. 'sort' => array(
  119. 'handler' => 'views_handler_sort',
  120. ),
  121. );
  122. $data['uc_product_kits']['synchronized'] = array(
  123. 'title' => t('Synchronized'),
  124. 'help' => t('A flag indicating that changes to the sell price of this product will change the total price of the kit. 1 => Yes. 0 => No.'),
  125. 'field' => array(
  126. 'handler' => 'views_handler_field_boolean',
  127. 'click sortable' => TRUE,
  128. ),
  129. 'filter' => array(
  130. 'handler' => 'views_handler_filter_boolean_operator',
  131. 'type' => 'yes-no',
  132. ),
  133. 'sort' => array(
  134. 'handler' => 'views_handler_sort',
  135. ),
  136. );
  137. $data['uc_product_kits']['is_kit_item'] = array(
  138. 'title' => t('Is part of a product kit'),
  139. 'help' => t('Check for the fields provided by the Ubercart product_kit module.'),
  140. 'group' => t('Node'),
  141. 'filter' => array(
  142. 'handler' => 'uc_product_kit_handler_filter_product_kit_item',
  143. 'label' => t('Is part of a product kit'),
  144. ),
  145. );
  146. $data['uc_product_kits']['is_kit'] = array(
  147. 'title' => t('Is a product kit'),
  148. 'help' => t('Check for the fields provided by the Ubercart product_kit module.'),
  149. 'group' => t('Node'),
  150. 'filter' => array(
  151. 'handler' => 'uc_product_kit_handler_filter_product_kit',
  152. 'label' => t('Is a product kit'),
  153. ),
  154. );
  155. return $data;
  156. }