huginn_bigcommerce_product_agent 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mapper/product_mapper.rb +33 -19
- 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: 6edc2db0f86f9193fa3463ca3a21db71bc52b06b007d1d00d81b934891eea499
|
4
|
+
data.tar.gz: f2635fda8a26cf5c0e7706c2be7794897769d0a99f3da2c243e61f96da069242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e730a73a5be204f43e0c54866f37e9e0e16542ad5357806d6dc1e69c41c0a3a9cd0ef9fb1c90b39982b3471dac0c61c23b0551ef60184ef9b66bfa878e0fa5f2
|
7
|
+
data.tar.gz: 628d7bd1ddf7dcfa831a3f34d0522c155eefcb99a90b39528a736251ed03d17480c30f9fa2a93def20af9aed0e6a6d31cea82333733a9ab10c910465c3e3284d
|
@@ -3,33 +3,47 @@ module BigcommerceProductAgent
|
|
3
3
|
class ProductMapper
|
4
4
|
|
5
5
|
def self.map(product, variant, additional_data = {}, is_digital = false, default_sku='')
|
6
|
-
|
7
|
-
|
6
|
+
name = product['name']
|
7
|
+
|
8
|
+
if variant
|
9
|
+
# variants inherit from and override parent product info
|
10
|
+
name = "#{name} (#{self.get_option(variant)})"
|
11
|
+
product = product.merge(variant)
|
12
|
+
else
|
13
|
+
# wrapper product
|
14
|
+
default_variant = self.get_variant_by_sku(product['sku'], product)
|
15
|
+
if default_variant
|
16
|
+
# pull up some properties from default variant (since bc doesn't display them otherwise)
|
17
|
+
product = {
|
18
|
+
"weight" => default_variant['weight'],
|
19
|
+
"width" => default_variant['width'],
|
20
|
+
"depth" => default_variant['depth'],
|
21
|
+
"height" => default_variant['height'],
|
22
|
+
}.merge(product)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
result = {
|
27
|
+
name: name,
|
8
28
|
sku: variant ? variant['sku'] : default_sku,
|
9
|
-
is_default:
|
10
|
-
type:
|
29
|
+
is_default: product['isDefault'],
|
30
|
+
type: product['isDigital'] == true || is_digital ? 'digital' : 'physical',
|
11
31
|
description: product['description'],
|
12
|
-
price:
|
32
|
+
price: product['offers'] && product['offers'][0] ? product['offers'][0]['price'] : '0',
|
13
33
|
categories: self.get_categories(product),
|
14
34
|
available: 'available',
|
15
|
-
weight:
|
16
|
-
width:
|
17
|
-
depth:
|
18
|
-
height:
|
35
|
+
weight: product['weight'] ? product['weight']['value'] : '0',
|
36
|
+
width: product['width'] ? product['width']['value'] : '0',
|
37
|
+
depth: product['depth'] ? product['depth']['value'] : '0',
|
38
|
+
height: product['height'] ? product['height']['value'] : '0',
|
19
39
|
meta_keywords: self.meta_keywords(product),
|
20
40
|
meta_description: self.meta_description(product),
|
21
41
|
search_keywords: self.meta_keywords(product).join(','),
|
22
|
-
is_visible: variant
|
23
|
-
}
|
24
|
-
|
25
|
-
|
26
|
-
upc = variant ? variant['gtin12'] : product['gtin12']
|
27
|
-
|
28
|
-
if upc
|
29
|
-
product[:upc] = upc
|
30
|
-
end
|
42
|
+
is_visible: variant ? false : true,
|
43
|
+
}
|
44
|
+
result[:upc] = product['gtin12'] if product['gtin12']
|
31
45
|
|
32
|
-
|
46
|
+
result.merge(additional_data)
|
33
47
|
end
|
34
48
|
|
35
49
|
def self.get_wrapper_sku(product)
|