magenthor 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/magenthor/catalog.rb +12 -3
- data/lib/magenthor/customer.rb +1 -22
- data/lib/magenthor/product.rb +31 -0
- data/lib/magenthor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 992999742b72ade0cd5d369d3e8a16901e8e80ec
|
|
4
|
+
data.tar.gz: 9c0480974cca0c110532637c0f1c8abd71577961
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d41b5c1b4a2caa42a0be341bff92f7b8de5984229398e7dcadfdea2cc22f52153411fc2d77a7cc2834781e3310709843efcca1904bfa196510b5249fa2d80630
|
|
7
|
+
data.tar.gz: a65c20444cfe0d3c252a260c04540a7e29466cbe7eb5e076b678641e1282770d494bdbae5108f9276531fb101468f70a87cfda5287be9a17f69b97a076e7d2b3
|
data/README.md
CHANGED
|
@@ -6,7 +6,9 @@ This code is inspired by, but not based on, [magentor gem](https://github.com/ps
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
$ gem install magenthor
|
|
10
|
+
|
|
11
|
+
This gem is still in an early stage of development and I discourage the installation except for debugging (or curiosity) purposes.
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
data/lib/magenthor/catalog.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Magenthor
|
|
|
5
5
|
class << self
|
|
6
6
|
# Get the list of all products sets
|
|
7
7
|
#
|
|
8
|
-
# @return [Array] a list of all attribute sets
|
|
8
|
+
# @return [Array, FalseClass] a list of all attribute sets or false
|
|
9
9
|
def attribute_set_list
|
|
10
10
|
commit('catalog_product_attribute_set.list', [])
|
|
11
11
|
end
|
|
@@ -13,9 +13,18 @@ module Magenthor
|
|
|
13
13
|
# Get the list of a attribute set
|
|
14
14
|
#
|
|
15
15
|
# @param set_id [String, Integer] the set id to get the attributes from
|
|
16
|
-
# @return [Array] a list of all attributes of the set
|
|
16
|
+
# @return [Array, FalseClass] a list of all attributes of the set or false
|
|
17
17
|
def attribute_list set_id
|
|
18
|
-
commit('catalog_product_attribute.list', [
|
|
18
|
+
commit('catalog_product_attribute.list', [set_id])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get the list of all additional attributes
|
|
22
|
+
#
|
|
23
|
+
# @param product_type [String] the type of the product
|
|
24
|
+
# @param set_id [String, Integer] the attribute set id
|
|
25
|
+
# @return [Array, FalseClass] a list of all additional attributes or false
|
|
26
|
+
def additional_attribute_list product_type, set_id
|
|
27
|
+
commit('product.listOfAdditionalAttributes', [product_type, set_id])
|
|
19
28
|
end
|
|
20
29
|
end
|
|
21
30
|
|
data/lib/magenthor/customer.rb
CHANGED
|
@@ -129,7 +129,7 @@ module Magenthor
|
|
|
129
129
|
customer_attributes.each do |a|
|
|
130
130
|
# Dynamic methods to find customers based on Magento attributes
|
|
131
131
|
define_method("find_by_#{a}") do |arg|
|
|
132
|
-
|
|
132
|
+
list({a.to_sym => arg})
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -140,27 +140,6 @@ module Magenthor
|
|
|
140
140
|
commit('customer_group.list', [])
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
private
|
|
145
|
-
|
|
146
|
-
# Method to find customers based on a specific Magento attribute, used to create the dynamic methods
|
|
147
|
-
#
|
|
148
|
-
# @param attribute [String] the attribute used to make the search
|
|
149
|
-
# @param value [String, Integer] the value of the attribute
|
|
150
|
-
# @return [Array<Magenthor::Customer>, Magenthor::Customer, FalseClass] the list of customer entities or a single customer entity or false
|
|
151
|
-
def find_by (attribute, value)
|
|
152
|
-
response = commit('customer.list', [attribute => value])
|
|
153
|
-
return false if response == false
|
|
154
|
-
if response.count > 1
|
|
155
|
-
customers = []
|
|
156
|
-
response.each do |r|
|
|
157
|
-
customers << find(r["customer_id"])
|
|
158
|
-
end
|
|
159
|
-
return customers
|
|
160
|
-
else
|
|
161
|
-
return new(response[0])
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
143
|
end
|
|
165
144
|
end
|
|
166
145
|
end
|
data/lib/magenthor/product.rb
CHANGED
|
@@ -61,7 +61,23 @@ module Magenthor
|
|
|
61
61
|
return true
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
# Delete from Magento the local product
|
|
65
|
+
#
|
|
66
|
+
# @return [TrueClass, FalseClass] true if successful or false
|
|
67
|
+
def delete
|
|
68
|
+
response = self.class.commit('catalog_product.delete', [self.product_id])
|
|
69
|
+
return false if response == false
|
|
70
|
+
|
|
71
|
+
methods.grep(/\w=$/).each do |m|
|
|
72
|
+
send(m, nil)
|
|
73
|
+
end
|
|
74
|
+
self.product_id = nil
|
|
75
|
+
|
|
76
|
+
return true
|
|
77
|
+
end
|
|
78
|
+
|
|
64
79
|
class << self
|
|
80
|
+
|
|
65
81
|
# Retrieve the list of Magento product based on filters and store view
|
|
66
82
|
#
|
|
67
83
|
# @param filters [Array] array of filters by attributes
|
|
@@ -92,6 +108,21 @@ module Magenthor
|
|
|
92
108
|
end
|
|
93
109
|
return obj
|
|
94
110
|
end
|
|
111
|
+
|
|
112
|
+
products_attributes = [
|
|
113
|
+
"sku",
|
|
114
|
+
"set",
|
|
115
|
+
"type",
|
|
116
|
+
"name",
|
|
117
|
+
"status",
|
|
118
|
+
"visibility"]
|
|
119
|
+
products_attributes.each do |a|
|
|
120
|
+
# Dynamic methods to find products based on Magento attributes
|
|
121
|
+
define_method("find_by_#{a}") do |arg|
|
|
122
|
+
list({a.to_sym => arg})
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
95
126
|
end
|
|
96
127
|
end
|
|
97
128
|
end
|
data/lib/magenthor/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: magenthor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniele Lenares
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-10-
|
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|