コード例 #1
0
 public function getManufacturers()
 {
     $sql = "\n\t\t\tSELECT \n\t\t\t\t`m`.* \n\t\t\tFROM \n\t\t\t\t`" . DB_PREFIX . "manufacturer` AS `m` \n\t\t\tINNER JOIN \n\t\t\t\t`" . DB_PREFIX . "manufacturer_to_store` AS `m2s` \n\t\t\tON \n\t\t\t\t`m`.`manufacturer_id` = `m2s`.`manufacturer_id` AND `m2s`.`store_id` = '" . (int) $this->config->get('config_store_id') . "'\n\t\t\t{join}\n\t\t\t{conditions}\n\t\t\t{group}\n\t\t\tORDER BY \n\t\t\t\t`m`.`sort_order` ASC,\n\t\t\t\t`m`.`name` ASC\n\t\t";
     $core = MegaFilterCore::newInstance($this, NULL);
     $data = MegaFilterCore::_getData($this);
     $join = '';
     $group = array();
     $conditions = $core->_baseConditions();
     $join = 'INNER JOIN `' . DB_PREFIX . 'product` AS `p` ON `p`.`manufacturer_id` = `m`.`manufacturer_id`';
     if (in_array($core->route(), MegaFilterCore::$_specialRoute)) {
         $conditions[] = '(' . $core->_specialCol('') . ') IS NOT NULL';
     }
     if (!empty($data['filter_name']) || !empty($data['filter_category_id']) || !empty($data['filter_manufacturer_id']) || !empty($conditions['search'])) {
         $join .= ' ' . $core->_baseJoin();
     }
     if ($join) {
         $group[] = '`m`.`manufacturer_id`';
     }
     $group = $group ? 'GROUP BY ' . implode(',', $group) : '';
     $conditions = $conditions ? 'WHERE ' . implode(' AND ', $conditions) : '';
     $sql = str_replace(array('{join}', '{conditions}', '{group}'), array($join, $conditions, $group), $sql);
     $manufacturers = array();
     foreach ($this->db->query($sql)->rows as $row) {
         $manufacturers[] = array('key' => $row['manufacturer_id'], 'value' => $row['manufacturer_id'], 'name' => $row['name'], 'image' => empty($row['image']) ? '' : $row['image']);
     }
     return $manufacturers;
 }
コード例 #2
0
ファイル: mega_filter.php プロジェクト: sasha-adm-in/project
 public function getManufacturers()
 {
     $sql = "\n\t\t\tSELECT \n\t\t\t\t`m`.* \n\t\t\tFROM \n\t\t\t\t`" . DB_PREFIX . "manufacturer` AS `m` \n\t\t\tINNER JOIN \n\t\t\t\t`" . DB_PREFIX . "manufacturer_to_store` AS `m2s` \n\t\t\tON \n\t\t\t\t`m`.`manufacturer_id` = `m2s`.`manufacturer_id` AND `m2s`.`store_id` = '" . (int) $this->config->get('config_store_id') . "'\n\t\t\t{join}\n\t\t\t{conditions}\n\t\t\t{group}\n\t\t\tORDER BY \n\t\t\t\t`m`.`sort_order` ASC,\n\t\t\t\t`m`.`name` ASC\n\t\t";
     $core = MegaFilterCore::newInstance($this, NULL);
     $data = MegaFilterCore::_getData($this);
     $join = '';
     $group = array();
     $conditions = $core->_baseConditions();
     $join = 'INNER JOIN `' . DB_PREFIX . 'product` AS `p` ON `p`.`manufacturer_id` = `m`.`manufacturer_id`';
     if (in_array($core->route(), MegaFilterCore::$_specialRoute)) {
         $conditions[] = '(' . $core->_specialCol('') . ') IS NOT NULL';
     }
     if (!empty($data['filter_name']) || !empty($data['filter_category_id']) || !empty($data['filter_manufacturer_id']) || !empty($conditions['search'])) {
         $join .= ' ' . $core->_baseJoin();
     }
     if ($join) {
         $group[] = '`m`.`manufacturer_id`';
     }
     $group = $group ? 'GROUP BY ' . implode(',', $group) : '';
     $conditions = $conditions ? 'WHERE ' . implode(' AND ', $conditions) : '';
     $sql = str_replace(array('{join}', '{conditions}', '{group}'), array($join, $conditions, $group), $sql);
     $manufacturers = array();
     $url = '';
     $path = '';
     $mfp = '';
     if (isset($this->request->get['path'])) {
         $path = 'path=' . $this->request->get['path'];
     }
     if (!empty($this->request->get['mfp'])) {
         if (strpos($this->request->get['mfp'], 'manufacturers') !== false) {
             $this->request->get['mfp'] = preg_replace("/manufacturers\\[\\d{1,}\\]/sim", '', $this->request->get['mfp']);
         }
     }
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     foreach ($this->db->query($sql)->rows as $row) {
         if (!empty($this->request->get['mfp'])) {
             $mfp = '&mfp=manufacturers[' . $row['manufacturer_id'] . '],' . $this->request->get['mfp'];
         } else {
             $mfp = '&mfp=manufacturers[' . $row['manufacturer_id'] . ']';
         }
         $manufacturers[] = array('key' => $row['manufacturer_id'], 'value' => $row['manufacturer_id'], 'name' => $row['name'], 'href' => $this->url->link('product/category', $path . $mfp . $url), 'image' => empty($row['image']) ? '' : $row['image']);
     }
     return $manufacturers;
 }