public function get_all_brands($filter = array())
{
$brands = array();
$category_id_filter = '';
$visible_filter = '';
if(isset($filter['visible']))
$visible_filter = $this->db->placehold('AND p.visible=?', intval($filter['visible']));
if(!empty($filter['category_id']))
$category_id_filter = $this->db->placehold("LEFT JOIN __products p ON p.brand_id=b.id LEFT JOIN __products_categories pc ON p.id = pc.product_id WHERE pc.category_id in(?@) $visible_filter", (array)$filter['category_id']);
// Выбираем все бренды
$query = $this->db->placehold("SELECT DISTINCT b.id, b.name, b.url, b.meta_title, b.meta_keywords, b.meta_description, b.description, b.image
FROM __brands b $category_id_filter ORDER BY b.name");
$this->db->query($query);
// return $this->db->results();
$bnds = $this->db->results();
foreach($bnds as $brnd){
$first_letter = mb_strtoupper(substr($brnd->name, 0, 1));
$otp[$first_letter][] = $brnd;
}
return $otp;
}