attribute.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * 前台品牌分类
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class attributeControl extends mobileHomeControl
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function effectOp()
  16. {
  17. $goods_attr_index_list = Model()->table('goods_attr_index')->field('attr_id')->distinct('attr_id')->where('1=1')->select();
  18. $attr_filter_list = array();
  19. foreach ($goods_attr_index_list as $value) {
  20. array_push($attr_filter_list, $value['attr_id']);
  21. }
  22. $attr_list = Model()->table('attribute')->where(array('attr_name' => '功效', 'attr_show' => '1', 'attr_id' => array('in', $attr_filter_list)))->select();
  23. $result = array();
  24. foreach ($attr_list as $value) {
  25. $type = Model()->table('type')->where(array('type_id' => $value['type_id']))->limit(1)->select();
  26. if (!empty($type)) {
  27. $fields = "attr_value_id,attr_value_name,attr_id,type_id";
  28. $attr_value_list = Model()->table('attribute_value')->field($fields)->where(array('attr_id' => $value['attr_id']))->select();
  29. $attr['type_name'] = $type[0]['type_name'];
  30. $attr['data'] = $attr_value_list;
  31. array_push($result, $attr);
  32. }
  33. }
  34. $attribute_list = array("attribute" => $result);
  35. joutput_data($attribute_list);
  36. }
  37. }