0

わかりました。カテゴリ ページに並べ替え変数をもう 1 つ追加したいと思います。つまり、製造元で並べ替えます。1.5.3.1 で実行し、これを試しました: 1.catalog/controller/product/category.php に以下を追加しました:

$this->data['sorts'][] = array(
            'text'  => $this->language->get('text_manufacturer_asc'),
            'value' => 'manufacturer-ASC',
            'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=manufacturer&order=ASC' . $url)
        );

$this->data['sorts'][] = array(
                'text'  => $this->language->get('text_manufacturer_desc'),
                'value' => 'manufacturer-DESC',
                'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=manufacturer&order=DESC' . $url)
            );
  1. catalog/language/*/product/category.php が追加されました:

    $_['text_manufacturer_asc'] = '▲ -Proizvođaču- ▲'; $_['text_manufacturer_desc'] = '▼ -Proizvođaču- ▼';

  2. catalog/model/catalog/product.php before: 'p.date_added' 行を挿入しました:

    'メーカー'

以下の数行で、ブロックを次のように変更しました。

    if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
    if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
        $sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
    } elseif ($data['sort'] == 'p.price') {
        $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
    } elseif ($data['sort'] == 'manufacturer') {
        $sql .= " SELECT * FROM". DB_PREFIX . "product p ORDER BY manufacturer";
    } else {
        $sql .= " ORDER BY " . $data['sort'];
    }
} else {
    $sql .= " ORDER BY p.sort_order";   
}

しかし、それは機能していません。エラーは言う:

PHP Notice:  Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROMproduct p ORDER BY manufacturer ASC,...

そして私が見つけた別のもの:

PHP Notice:  Error: Unknown column 'special' in 'order clause'<br />Error No: 1054<br />SELECT p.product_id, (SELECT AVG(rating) AS total FROM review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id)...

誰でも助けることができますか?

4

1 に答える 1