uc_product_handler_field_display_price.inc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Views handler: Product price field.
  5. */
  6. /**
  7. * Returns a formatted price value to display in the View.
  8. */
  9. class uc_product_handler_field_display_price extends uc_product_handler_field_price {
  10. /**
  11. * Overrides views_handler::option_definition().
  12. */
  13. function option_definition() {
  14. $options = parent::option_definition();
  15. $options['label']['default'] = t('Price');
  16. return $options;
  17. }
  18. /**
  19. * Overrides views_handler_field::get_value().
  20. */
  21. function get_value($values, $field = NULL) {
  22. $nid = parent::get_value($values, $field);
  23. // !TODO Refactor so that all variants are loaded at once in the pre_render hook.
  24. $node = node_view(node_load($nid), 'teaser');
  25. return $node['display_price']['#value'];
  26. }
  27. /**
  28. * Overrides views_handler_field::click_sort().
  29. */
  30. function click_sort($order) {
  31. $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
  32. $this->query->add_orderby(NULL, NULL, $order, 'sell_price', $params);
  33. }
  34. }