<?php
/*
 * simonfilters - 2.5.0 Build 0011
 */

class ModelCatalogFilter extends Model {

    public function getPossibleFilters($language_id) {
        $data = Array(
                
                'options'=>$this->db->query("SELECT od.option_id as id, name FROM ". DB_PREFIX ."option_description od WHERE od.language_id={$language_id} ORDER BY name")->rows,
                'manufacturer'=>$this->db->query("select m.manufacturer_id as id, name from ". DB_PREFIX ."manufacturer m ORDER BY name")->rows,
                'attribute'=>$this->db->query("
                    SELECT a.attribute_id as id, ad.name as name, agd.name as groupname, agd.attribute_group_id
                    FROM ". DB_PREFIX ."attribute a
                    JOIN ". DB_PREFIX ."attribute_description ad ON a.attribute_id = ad.attribute_id
                    JOIN ". DB_PREFIX ."attribute_group_description agd ON a.attribute_group_id = agd.attribute_group_id AND ad.language_id = agd.language_id
                    WHERE ad.language_id='{$language_id}'
                    ORDER BY ad.name
                ")->rows,
                'stock'=>$this->db->query("SELECT stock_status_id as id, name FROM ". DB_PREFIX ."stock_status WHERE language_id='{$language_id}' ORDER BY name")->rows,
                'tags'=>$this->db->query("select pt.product_tag_id, pt.tag from ". DB_PREFIX ."product_tag pt where language_id='{$language_id}' group by tag ORDER BY pt.tag")->rows,
                'categories'=>$this->db->query("SELECT c.category_id, cd.name FROM ". DB_PREFIX ."category c JOIN ". DB_PREFIX ."category_description cd ON c.category_id = cd.category_id WHERE c.parent_id=0 AND cd.language_id='{$language_id}' AND c.status=1")->rows
        );
        return $data;
    }
}