uc_product.views.inc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks for Ubercart products.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function uc_product_views_data() {
  10. $data['uc_products']['table']['group'] = t('Product');
  11. $data['uc_products']['table']['join'] = array(
  12. 'node' => array(
  13. 'left_field' => 'vid',
  14. 'field' => 'vid',
  15. ),
  16. 'node_revisions' => array(
  17. 'left_field' => 'vid',
  18. 'field' => 'vid',
  19. ),
  20. );
  21. $data['uc_products']['model'] = array(
  22. 'title' => t('SKU'),
  23. 'help' => t('The model number.'),
  24. 'field' => array(
  25. 'handler' => 'views_handler_field_node',
  26. 'click sortable' => TRUE,
  27. ),
  28. 'sort' => array(
  29. 'handler' => 'views_handler_sort',
  30. ),
  31. 'filter' => array(
  32. 'handler' => 'views_handler_filter_string',
  33. ),
  34. 'argument' => array(
  35. 'handler' => 'views_handler_argument_string',
  36. ),
  37. );
  38. $data['uc_products']['list_price'] = array(
  39. 'title' => t('List price'),
  40. 'help' => t("The manufacturer's suggested price."),
  41. 'field' => array(
  42. 'handler' => 'uc_product_handler_field_price',
  43. 'click sortable' => TRUE,
  44. 'float' => TRUE,
  45. 'additional fields' => array(
  46. 'nid' => array(
  47. 'table' => 'node',
  48. 'field' => 'nid',
  49. ),
  50. ),
  51. ),
  52. 'sort' => array(
  53. 'handler' => 'views_handler_sort',
  54. ),
  55. 'filter' => array(
  56. 'handler' => 'views_handler_filter_numeric',
  57. ),
  58. );
  59. $data['uc_products']['cost'] = array(
  60. 'title' => t('Cost'),
  61. 'help' => t('The cost of the product to the store.'),
  62. 'field' => array(
  63. 'handler' => 'uc_product_handler_field_price',
  64. 'click sortable' => TRUE,
  65. 'float' => TRUE,
  66. 'additional fields' => array(
  67. 'nid' => array(
  68. 'table' => 'node',
  69. 'field' => 'nid',
  70. ),
  71. ),
  72. ),
  73. 'sort' => array(
  74. 'handler' => 'views_handler_sort',
  75. ),
  76. 'filter' => array(
  77. 'handler' => 'views_handler_filter_numeric',
  78. ),
  79. );
  80. $data['uc_products']['sell_price'] = array(
  81. 'title' => t('Sell price'),
  82. 'help' => t('The price for which the product is sold.'),
  83. 'field' => array(
  84. 'handler' => 'uc_product_handler_field_price',
  85. 'click sortable' => TRUE,
  86. 'float' => TRUE,
  87. 'additional fields' => array(
  88. 'nid' => array(
  89. 'table' => 'node',
  90. 'field' => 'nid',
  91. ),
  92. ),
  93. ),
  94. 'sort' => array(
  95. 'handler' => 'views_handler_sort',
  96. ),
  97. 'filter' => array(
  98. 'handler' => 'views_handler_filter_numeric',
  99. ),
  100. );
  101. $data['uc_products']['display_price'] = array(
  102. 'title' => t('Display price'),
  103. 'help' => t('The price for which the product is sold, altered for display (e.g. with inclusive taxes).'),
  104. 'field' => array(
  105. 'handler' => 'uc_product_handler_field_display_price',
  106. 'real field' => 'nid',
  107. 'click sortable' => TRUE,
  108. ),
  109. );
  110. $data['uc_products']['weight'] = array(
  111. 'title' => t('Weight'),
  112. 'help' => t('The physical weight.'),
  113. 'field' => array(
  114. 'additional fields' => array(
  115. 'field' => 'weight_units',
  116. ),
  117. 'handler' => 'uc_product_handler_field_weight',
  118. 'click sortable' => TRUE,
  119. 'float' => TRUE,
  120. ),
  121. 'sort' => array(
  122. 'handler' => 'views_handler_sort',
  123. ),
  124. 'filter' => array(
  125. 'handler' => 'views_handler_filter_numeric',
  126. ),
  127. );
  128. $data['uc_products']['length'] = array(
  129. 'title' => t('Length'),
  130. 'help' => t('The physical length.'),
  131. 'field' => array(
  132. 'additional fields' => array(
  133. 'field' => 'length_units',
  134. ),
  135. 'handler' => 'uc_product_handler_field_length',
  136. 'click sortable' => TRUE,
  137. 'float' => TRUE,
  138. ),
  139. 'sort' => array(
  140. 'handler' => 'views_handler_sort',
  141. ),
  142. 'filter' => array(
  143. 'handler' => 'views_handler_filter_float',
  144. ),
  145. );
  146. $data['uc_products']['width'] = array(
  147. 'title' => t('Width'),
  148. 'help' => t('The physical width.'),
  149. 'field' => array(
  150. 'additional fields' => array(
  151. 'field' => 'length_units',
  152. ),
  153. 'handler' => 'uc_product_handler_field_length',
  154. 'click sortable' => TRUE,
  155. 'float' => TRUE,
  156. ),
  157. 'sort' => array(
  158. 'handler' => 'views_handler_sort',
  159. ),
  160. 'filter' => array(
  161. 'handler' => 'views_handler_filter_float',
  162. ),
  163. );
  164. $data['uc_products']['height'] = array(
  165. 'title' => t('Height'),
  166. 'help' => t('The physical height.'),
  167. 'field' => array(
  168. 'additional fields' => array(
  169. 'field' => 'length_units',
  170. ),
  171. 'handler' => 'uc_product_handler_field_length',
  172. 'click sortable' => TRUE,
  173. 'float' => TRUE,
  174. ),
  175. 'sort' => array(
  176. 'handler' => 'views_handler_sort',
  177. ),
  178. 'filter' => array(
  179. 'handler' => 'views_handler_filter_float',
  180. ),
  181. );
  182. $data['uc_products']['pkg_qty'] = array(
  183. 'title' => t('Package quantity'),
  184. 'help' => t('The number of items that fit in the largest package.'),
  185. 'field' => array(
  186. 'handler' => 'views_handler_field_numeric',
  187. 'click sortable' => TRUE,
  188. ),
  189. 'sort' => array(
  190. 'handler' => 'views_handler_sort',
  191. ),
  192. 'filter' => array(
  193. 'handler' => 'views_handler_filter_numeric',
  194. ),
  195. );
  196. $data['uc_products']['ordering'] = array(
  197. 'title' => t('List position'),
  198. 'help' => t('The default sort criteria in the catalog.'),
  199. 'field' => array(
  200. 'help' => t("The product list position."),
  201. 'handler' => 'views_handler_field_numeric',
  202. ),
  203. 'sort' => array(
  204. 'handler' => 'views_handler_sort',
  205. ),
  206. );
  207. $data['uc_products']['shippable'] = array(
  208. 'title' => t('Shippable'),
  209. 'help' => t('Is the product shippable?'),
  210. 'field' => array(
  211. 'handler' => 'views_handler_field_boolean',
  212. 'click sortable' => TRUE,
  213. ),
  214. 'sort' => array(
  215. 'handler' => 'views_handler_sort',
  216. ),
  217. 'filter' => array(
  218. 'handler' => 'views_handler_filter_boolean_operator',
  219. ),
  220. );
  221. $data['uc_products']['is_product'] = array(
  222. 'title' => t('Is a product'),
  223. 'help' => t('Check for the fields provided by the Ubercart product module.'),
  224. 'group' => t('Node'),
  225. 'filter' => array(
  226. 'handler' => 'uc_product_handler_filter_product',
  227. 'label' => t('Is a product'),
  228. ),
  229. );
  230. $data['uc_products']['addtocartlink'] = array(
  231. 'title' => t('Add to cart form'),
  232. 'help' => t("Form to put the product in the customer's cart."),
  233. 'group' => t('Product'),
  234. 'field' => array(
  235. 'additional fields' => array(
  236. 'nid' => array(
  237. 'table' => 'node',
  238. 'field' => 'nid',
  239. ),
  240. 'type' => array(
  241. 'table' => 'node',
  242. 'field' => 'type',
  243. ),
  244. ),
  245. 'handler' => 'uc_product_handler_field_addtocart',
  246. 'element type' => 'div',
  247. ),
  248. );
  249. $data['uc_products']['buyitnowbutton'] = array(
  250. 'title' => t('Buy it now button'),
  251. 'help' => t('A button to add a product to the cart without quantity or attribute fields.'),
  252. 'group' => t('Product'),
  253. 'field' => array(
  254. 'table' => 'node',
  255. 'additional fields' => array(
  256. 'nid' => array(
  257. 'table' => 'node',
  258. 'field' => 'nid',
  259. ),
  260. ),
  261. 'handler' => 'uc_product_handler_field_buyitnow',
  262. 'element type' => 'div',
  263. ),
  264. );
  265. return $data;
  266. }