Jump to content
Sign in to follow this  
alexeylobas

Сортировка по наличию

Recommended Posts

У меня да и наверно как и у всех стоит сортировка "По умолчанию" , а как сделать чтобы товары с количеством "0" выводились в конце изначально ?= Это приоритет !

Ну а если такое возможно , ещё и реализовать  смену цвета как на скрине

Edited by alexeylobas

Share this post


Link to post
Share on other sites

Да действительно решение есть  по сортировке по наличию , а как сделать что бы цвет менялся ?

Share this post


Link to post
Share on other sites

Мне подошло только одно решение: в catalog\model\catalog\product.php

 

вот это:

  1. if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
  2.             if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
  3.                 $sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
  4.             } elseif ($data['sort'] == 'p.price') {
  5.                 $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
  6.             } else {
  7.                 $sql .= " ORDER BY " . $data['sort'];
  8.             }
  9.         } else {
  10.             $sql .= " ORDER BY p.sort_order";    
  11.         }

на это :

 

  1. if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
  2.             if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
  3.                 $sql .= " ORDER BY (p.quantity>0) DESC, LCASE(" . $data['sort'] . ")";
  4.             } elseif ($data['sort'] == 'p.price') {
  5.                 $sql .= " ORDER BY (p.quantity>0) DESC, (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
  6.             } else {
  7.                 $sql .= " ORDER BY (p.quantity>0) DESC," . $data['sort'];
  8.             }
  9.         } else {
  10.             $sql .= " ORDER BY (p.quantity>0) DESC, p.sort_order";    
  11.         }

как тут можно ещё подправить цвет товаров с количеством "0" , или где это можно сделать?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.