- Автор темы
- #1
Уже голову сломал, как можно отсортировать в мегафильтр про. Вот код ниже предоставил, только по названию работает.
Код:
public function getManufacturers() {
$sql = "
SELECT
`m`.*
FROM
`" . DB_PREFIX . "manufacturer` AS `m`
INNER JOIN
`" . DB_PREFIX . "manufacturer_to_store` AS `m2s`
ON
`m`.`manufacturer_id` = `m2s`.`manufacturer_id` AND `m2s`.`store_id` = '" . (int)$this->config->get('config_store_id') . "'
{join}
{conditions}
{group}
ORDER BY
`m`.`name` ASC
";
$core = MegaFilterCore::newInstance( $this, NULL, array(), $this->settings() );
$data = MegaFilterCore::_getData( $this );
$join = '';
$group = array();
$conditions = $core->_baseConditions( array(), true );
$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( $this->request->get['mfp_path'] ) || ! 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;
}
Последнее редактирование: