magento 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -19
- data/lib/magento/query.rb +9 -0
- data/magento.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02761b4b3a2e3b5da2082816534436f4f007f5f657b32400483bfd36d02f610b
|
4
|
+
data.tar.gz: 98e66dfd540d759b3e024de58bc43575b1c3437864584c4797d27391e5ec279e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9523a813be0fc77cc4fea9a751b639994a1a8e03869326ae967b9b98bcee93edcdc03f81abae60110514a5833fc5d123d91c634af5bd149d7ff586e732b77db9
|
7
|
+
data.tar.gz: 40bba87521d8624056cee96a8832a6dfcaf99353c9c69038684e8bf7d29cd7d9883fd97330eb45e646a438415bb533934cbccca6847770e41255b38d4c237ebb
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Add in your Gemfile
|
6
6
|
|
7
7
|
```rb
|
8
|
-
gem 'magento', '~> 0.3.
|
8
|
+
gem 'magento', '~> 0.3.2'
|
9
9
|
```
|
10
10
|
|
11
11
|
or run
|
@@ -66,27 +66,35 @@ Magento::Product.select(:id, :sku, :name, extension_attributes: [:website_ids, {
|
|
66
66
|
```rb
|
67
67
|
Magento::Product.where(name_like: 'IPhone%').all
|
68
68
|
Magento::Product.where(price_gt: 100).all
|
69
|
-
|
69
|
+
|
70
|
+
# price > 10 AND price < 20
|
71
|
+
Magento::Product.where(price_gt: 10)
|
72
|
+
.where(price_lt: 20).all
|
73
|
+
|
74
|
+
# price < 1 OR price > 100
|
75
|
+
Magento::Product.where(price_lt: 1, price_gt: 100).all
|
76
|
+
|
77
|
+
Magento::Order.where(status_in: [:canceled, :complete]).all
|
70
78
|
```
|
71
79
|
|
72
80
|
| Condition | Notes |
|
73
|
-
|
|
74
|
-
|eq
|
75
|
-
|finset
|
76
|
-
|from
|
77
|
-
|gt
|
78
|
-
|gteq
|
79
|
-
|in
|
80
|
-
|like
|
81
|
-
|lt
|
82
|
-
|lteq
|
83
|
-
|moreq
|
84
|
-
|neq
|
85
|
-
|nfinset
|
86
|
-
|nin
|
87
|
-
|notnull
|
88
|
-
|null
|
89
|
-
|to
|
81
|
+
| --------- | ----- |
|
82
|
+
|eq | Equals. |
|
83
|
+
|finset | A value within a set of values |
|
84
|
+
|from | The beginning of a range. Must be used with to |
|
85
|
+
|gt | Greater than |
|
86
|
+
|gteq | Greater than or equal |
|
87
|
+
|in | In. The value is an array |
|
88
|
+
|like | Like. The value can contain the SQL wildcard characters when like is specified. |
|
89
|
+
|lt | Less than |
|
90
|
+
|lteq | Less than or equal |
|
91
|
+
|moreq | More or equal |
|
92
|
+
|neq | Not equal |
|
93
|
+
|nfinset | A value that is not within a set of values |
|
94
|
+
|nin | Not in. The value is an array |
|
95
|
+
|notnull | Not null |
|
96
|
+
|null | Null |
|
97
|
+
|to | The end of a range. Must be used with from |
|
90
98
|
|
91
99
|
|
92
100
|
#### SortOrder:
|
data/lib/magento/query.rb
CHANGED
@@ -38,6 +38,7 @@ module Magento
|
|
38
38
|
filters = []
|
39
39
|
attributes.each do |key, value|
|
40
40
|
field, condition = parse_filter(key)
|
41
|
+
value = parse_value_filter(condition, value)
|
41
42
|
filters << { field: field, conditionType: condition, value: value }
|
42
43
|
end
|
43
44
|
filter_groups << { filters: filters }
|
@@ -115,6 +116,14 @@ module Magento
|
|
115
116
|
key.match(patter).to_a[1..2]
|
116
117
|
end
|
117
118
|
|
119
|
+
def parse_value_filter(condition, value)
|
120
|
+
if ['in', 'nin'].include?(condition) && value.is_a?(Array)
|
121
|
+
value = value.join(',')
|
122
|
+
end
|
123
|
+
|
124
|
+
value
|
125
|
+
end
|
126
|
+
|
118
127
|
def parse_field(value)
|
119
128
|
return verify_id(value) unless value.is_a? Hash
|
120
129
|
|
data/magento.gemspec
CHANGED