magento_remote 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/magento_show_last_order +13 -1
- data/lib/magento_remote/magento_mech.rb +11 -0
- data/lib/magento_remote/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDdiMDk3MTBjMjA1Y2MwZmEwMGI5OWY1ZTE5YmMwMDg2OTU3MWJjMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTg5NTg2ZDNiZGE1OGE3OGUzNDgwYjFlMDdlNjMyZjYxOTg5NmY0Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDNmZTkwODcyZWY3NDFiODcyMzA1YmZmOGI5NzhkZGM0NDAwYjdhZWY0MzJi
|
10
|
+
NWY3NTlhNGUxMmI0ODk2Yzk3N2Y4OTgyMGQ0ZDc0NzU3NTAzNzQ4N2Y5ZDg1
|
11
|
+
MjNiOWIwZGFiNWM0YmQzMWFkYzFhMzcyZTg4ZTNhMTlkYjA2ZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWY3NGI4OWU0NDM4YWVkNWY5MWZkOWU3MzM2OTdlMjI2ZmFkNTZlYjg5MjA3
|
14
|
+
OGE0MTY1MDFhN2E1M2FiMTBjMDA4MTY2NzRiMGEzNmJjMjA4MmM3NGNhMGM5
|
15
|
+
Y2YzNmJmNWYzZmQ5NzVjMjc2ZWMyMDc5NjcyMjFhNWYwOTU5ODk=
|
data/bin/magento_show_last_order
CHANGED
@@ -12,6 +12,13 @@ program_name = File.basename __FILE__
|
|
12
12
|
optparse = OptionParser.new do |opts|
|
13
13
|
opts.banner = "Usage: #{program_name} [OPTIONS]\n Show last order."
|
14
14
|
|
15
|
+
opts.separator ""
|
16
|
+
opts.separator "Order options"
|
17
|
+
|
18
|
+
opts.on("-o", '--order-id ORDERID', 'order id in shop.') do |o|
|
19
|
+
options[:order_id] = o
|
20
|
+
end
|
21
|
+
|
15
22
|
opts.separator ""
|
16
23
|
opts.separator "Magento shop options"
|
17
24
|
|
@@ -67,7 +74,12 @@ return_code = 0
|
|
67
74
|
|
68
75
|
mech.login
|
69
76
|
|
70
|
-
|
77
|
+
if options[:order_id]
|
78
|
+
products = mech.products_from_order options[:order_id]
|
79
|
+
else
|
80
|
+
products = mech.last_order_products
|
81
|
+
end
|
82
|
+
|
71
83
|
if products.empty?
|
72
84
|
puts "Nothing found"
|
73
85
|
else
|
@@ -203,6 +203,17 @@ class MagentoMech
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
+
def products_from_order order_id
|
207
|
+
order_url = relative_url("/sales/order/view/order_id/#{order_id}/")
|
208
|
+
@mech.get order_url
|
209
|
+
@mech.page.search('tr.border').map do |tr|
|
210
|
+
product_name = tr.children[1].children[0].content
|
211
|
+
product_sku = tr.children[3].children[0].content
|
212
|
+
product_qty = tr.children[7].children[1].content[/\d+/]
|
213
|
+
[product_name, product_sku, product_qty]
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
206
217
|
private
|
207
218
|
|
208
219
|
# Construct path relative to base uri.
|