-
Notifications
You must be signed in to change notification settings - Fork 2
/
order-out-of-stock-products-to-end.ocmod.xml
42 lines (42 loc) · 1.39 KB
/
order-out-of-stock-products-to-end.ocmod.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Move out of stock products to end</name>
<code>move-out-of-stock-products-to-end</code>
<version>1.0</version>
<author>Rafael Marques</author>
<link>https://www.rafaelmarques.me</link>
<file path="catalog/model/catalog/product.php">
<operation>
<search index="0">
<![CDATA[if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {]]>
</search>
<add position="before">
<![CDATA[$sql .= " ORDER BY (p.quantity > 0) DESC, ";]]>
</add>
</operation>
<operation>
<search>
<![CDATA[$sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";]]>
</search>
<add position="replace">
<![CDATA[$sql .= " (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";]]>
</add>
</operation>
<operation>
<search index="0">
<![CDATA[$sql .= " ORDER BY " . $data['sort'];]]>
</search>
<add position="replace">
<![CDATA[$sql .= $data['sort'];]]>
</add>
</operation>
<operation>
<search index="0">
<![CDATA[$sql .= " ORDER BY p.sort_order";]]>
</search>
<add position="replace">
<![CDATA[$sql .= " p.sort_order";]]>
</add>
</operation>
</file>
</modification>