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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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.