<?php
/**
 * 前台品牌分类
 *
 *
 *
 ***/


defined('InShopNC') or exit('Access Invalid!');

class attributeControl extends mobileHomeControl
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 查询功效列表(已废)
     */
    public function effectOp()
    {
        $goods_attr_index_list = Model()->table('goods_attr_index')->field('attr_id')->distinct('attr_id')->where('1=1')->select();

        $attr_filter_list = array();
        foreach ($goods_attr_index_list as $value) {
            array_push($attr_filter_list, $value['attr_id']);
        }

        $attr_list = Model()->table('attribute')->where(array('attr_name' => '功效', 'attr_show' => '1', 'attr_id' => array('in', $attr_filter_list)))->select();

        $result = array();
        foreach ($attr_list as $value) {
            $type = Model()->table('type')->where(array('type_id' => $value['type_id']))->limit(1)->select();
            if (!empty($type)) {

                $fields = "attr_value_id,attr_value_name,attr_id,type_id";
                $attr_value_list = Model()->table('attribute_value')->field($fields)->where(array('attr_id' => $value['attr_id']))->select();

                $attr['type_name'] = $type[0]['type_name'];
                $attr['data'] = $attr_value_list;
                array_push($result, $attr);
            }
        }

        $attribute_list = array("attribute" => $result);
        joutput_data($attribute_list);
    }
}
