D
D
del4pp2020-07-31 16:33:52
opencart
del4pp, 2020-07-31 16:33:52

Sorting in opencart 3 by default?

Hello.
How to make sorting "by rating" open by default?
I changed $sort in catalog/controller/product/category.php
to all possible values, updated the modifier, nothing changed.

Version ocStore 3.0.2.0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VVCh, 2020-08-02
@del4pp

Changed in catalog/controller/product/category.php

What changed?
Have you looked at the model?
$sort_data = array(
      'pd.name',
      'p.model',
      'p.quantity',
      'p.price',
      'rating',
      'p.sort_order',
      '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)";
      } else {
        $sql .= " ORDER BY " . $data['sort'];
      }
    } else {
      $sql .= " ORDER BY p.sort_order";
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question