huginn_bigcommerce_product_agent 2.2.0 → 2.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27cf670464183919a89406859de8c626afc22dde8215131409a8c6a7216c905e
|
4
|
+
data.tar.gz: ab101f6ffbd97154e08f251aefcd1e5160976d8155c84796a9c6969e2c004eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05416caf4092031603db2a0fadf8153f4774fa2d39532a2df58af356f4da12e18f37b96df24eeacaed4a1607796e1395433b92c30b35d4600897db189ce8254f
|
7
|
+
data.tar.gz: 42fd87774053b50615271eb2b3f8955c4ae032999c9483a041deb510d87d08c1396353b00f0968d6e658fd8c8f5e5a0122dae8686df53fa63f8fbf22891c112f
|
data/lib/client/product.rb
CHANGED
@@ -94,7 +94,11 @@ module BigcommerceProductAgent
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# When using sku:in you must specify the fields you want returned.
|
97
|
-
def get_by_skus(
|
97
|
+
def get_by_skus(
|
98
|
+
skus,
|
99
|
+
include = %w[custom_fields modifiers],
|
100
|
+
include_fields = %w[sku categories inventory_tracking is_visible]
|
101
|
+
)
|
98
102
|
products = []
|
99
103
|
skus.each do |sku|
|
100
104
|
begin
|
@@ -25,7 +25,6 @@ module Agents
|
|
25
25
|
'meta_fields_namespace' => '',
|
26
26
|
'not_purchasable_format_list' => [],
|
27
27
|
'should_disambiguate' => false,
|
28
|
-
|
29
28
|
}
|
30
29
|
end
|
31
30
|
|
@@ -347,7 +346,7 @@ module Agents
|
|
347
346
|
if (track_inventory)
|
348
347
|
track_inventory = boolify(raw_product['trackInventory'])
|
349
348
|
end
|
350
|
-
bc_payload = get_mapper(:ProductMapper).map_payload(raw_product, additional_data, track_inventory)
|
349
|
+
bc_payload = get_mapper(:ProductMapper).map_payload(raw_product, bc_product, additional_data, track_inventory)
|
351
350
|
bc_payload['id'] = bc_product['id'] unless bc_product.nil? || bc_product['id'].nil?
|
352
351
|
# NOTE: bc_product will be nil when this is called with `to_create` products
|
353
352
|
|
@@ -2,12 +2,19 @@ module BigcommerceProductAgent
|
|
2
2
|
module Mapper
|
3
3
|
class ProductMapper
|
4
4
|
|
5
|
-
def self.map_payload(product, additional_data = {}, track_inventory = true, default_sku = '')
|
5
|
+
def self.map_payload(product, bc_product, additional_data = {}, track_inventory = true, default_sku = '')
|
6
6
|
name = product['name']
|
7
7
|
isDigital = product['isDigital'].to_s == 'true'
|
8
8
|
|
9
9
|
track_inventory = self.get_availability(product) == 'preorder' ? false : track_inventory
|
10
10
|
|
11
|
+
# respect the visibility setting of existing products, otherwise
|
12
|
+
# default visibility to true.
|
13
|
+
is_visible = true
|
14
|
+
if !bc_product.nil? && !bc_product['is_visible'].nil?
|
15
|
+
is_visible = bc_product['is_visible']
|
16
|
+
end
|
17
|
+
|
11
18
|
result = {
|
12
19
|
availability: self.get_availability(product),
|
13
20
|
categories: self.get_categories(product),
|
@@ -15,8 +22,8 @@ module BigcommerceProductAgent
|
|
15
22
|
description: product['description'] || '',
|
16
23
|
height: product['height'] ? product['height']['value'] : '0',
|
17
24
|
is_default: product['isDefault'],
|
18
|
-
is_preorder_only:
|
19
|
-
is_visible:
|
25
|
+
is_preorder_only: false,
|
26
|
+
is_visible: is_visible,
|
20
27
|
meta_description: self.meta_description(product) || '',
|
21
28
|
meta_keywords: self.meta_keywords(product),
|
22
29
|
name: name,
|
@@ -30,8 +37,37 @@ module BigcommerceProductAgent
|
|
30
37
|
type: isDigital ? 'digital' : 'physical',
|
31
38
|
weight: product['weight'] ? product['weight']['value'] : '0',
|
32
39
|
width: product['width'] ? product['width']['value'] : '0',
|
33
|
-
inventory_tracking: isDigital || !track_inventory ? 'none' : 'product',
|
34
40
|
}
|
41
|
+
|
42
|
+
# BEGIN: The following block is a workaround for a BigCommerce bug.
|
43
|
+
#
|
44
|
+
# It seems that when the `inventory_tracking` attribute is included in the payload,
|
45
|
+
# BigCommerce is now triggering a low stock warning for products with inventory
|
46
|
+
# tracking disabled.
|
47
|
+
#
|
48
|
+
# We are currently seeing notifications for _every digital product_ each time
|
49
|
+
# the sync process runs.
|
50
|
+
#
|
51
|
+
# Pending a fix from BigCommerce the following logic is designed to mitigate
|
52
|
+
# the false alarms. Essentially, we will only be including the `inventory_tracking`
|
53
|
+
# attribute if the value is _changing_ from whatever is currently set.
|
54
|
+
# While this may not stop _all_ of the false alarms, it should reduce them
|
55
|
+
# significantly.
|
56
|
+
current_tracking_value = bc_product['inventory_tracking'] unless bc_product.nil?
|
57
|
+
new_tracking_value = isDigital || !track_inventory ? 'none' : 'product'
|
58
|
+
|
59
|
+
if (current_tracking_value != new_tracking_value)
|
60
|
+
result[:inventory_tracking] = new_tracking_value
|
61
|
+
end
|
62
|
+
# END: Stock warning workaround
|
63
|
+
|
64
|
+
|
65
|
+
stock = get_additional_property_value(product, 'product_inventory', 0)
|
66
|
+
|
67
|
+
if (stock)
|
68
|
+
result[:inventory_level] = stock
|
69
|
+
end
|
70
|
+
|
35
71
|
result[:upc] = product['isbn'] ? product['isbn'] : product['gtin12']
|
36
72
|
result[:gtin] = product['gtin12'] if product['gtin12']
|
37
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_bigcommerce_product_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Spizziri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.0.3
|
95
|
+
rubygems_version: 3.0.3.1
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Agent that takes a generic product interface and upserts that product in
|