huginn_bigcommerce_product_agent 1.4.3 → 1.5.0

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: 4d9046f3fa0d6c9e3f0c58720148502c622ec9662cecc03488d381f5c7730440
4
- data.tar.gz: 15652aee1e058bffc5a15920574bd93c7eb89ba0391c267cb6912c270a1f0810
3
+ metadata.gz: 728526f71b899d714ffeaf9cca25b150326ba889dc17c732ace2c41b7b92782e
4
+ data.tar.gz: d237a9f1a6eb179f76679a7a870b56a7844239ee45f4fd32f56ba8a296201ca9
5
5
  SHA512:
6
- metadata.gz: b75f6cc9fbfabb4c0143b33146d1c736fd4680657642c29e755621e12a5d1d5efb6aa1aadc4d3ee6494dea17d1f6dab20d34a15aacf8ec992be8c79430d89fc3
7
- data.tar.gz: 3fe2de4e3330ae759ef8e43b402a6a5ca7ac9e1ce21dac24c8ff2bbdb0e8680ca2fcde53f129d6ae5358a07d3f9e237eae08ae8b1c0fc1f378b3c880082d5239
6
+ metadata.gz: 54e4aa00c7216da7c8d66ba4ea45cbcd1ec51339982686719505f2806761a91e601d807165c194975777e9b7ae0ee8327cde0d9ee966ccee264659d70b083ee1
7
+ data.tar.gz: 9e9ff91a64dbab6ac8e0a1b599a5415ce2744d39cf00e3ca12d697fddde434dcf9aa174ecd89b0e67333838bd03cfe8585797c6d9e50c73cd57b936eb3ed8b9a
@@ -124,6 +124,16 @@ module Agents
124
124
  wrapper_skus.map {|k,v| v},
125
125
  %w[custom_fields options]
126
126
  )
127
+ #save skus
128
+ digital_skus = []
129
+ physical_skus = []
130
+ if split[:digital] and split[:physical]
131
+ digital_skus.concat([wrapper_skus[:digital]])
132
+ digital_skus.concat(get_mapper(:ProductMapper).get_product_skus(split[:digital])).join(",")
133
+ physical_skus.concat([wrapper_skus[:physical]])
134
+ physical_skus.concat(get_mapper(:ProductMapper).get_product_skus(split[:physical])).join(",")
135
+ end
136
+
127
137
  # upsert wrapper products
128
138
  split.each do |type, product|
129
139
  is_digital = type == :digital ? true : false
@@ -138,10 +148,11 @@ module Agents
138
148
  variant_option_name = get_mapper(:OptionMapper).variant_option_name
139
149
  bc_option = !bc_product.nil? ? bc_product['options'].select {|opt| opt['display_name'] === variant_option_name}.first : nil
140
150
 
151
+ search_skus = is_digital ? physical_skus : digital_skus
141
152
  # ##############################
142
153
  # 1. update wrapper product
143
154
  # ##############################
144
- upsert_result = upsert_product(wrapper_sku, product, bc_product, is_digital)
155
+ upsert_result = upsert_product(wrapper_sku, product, bc_product, is_digital, search_skus)
145
156
  bc_product = upsert_result[:product]
146
157
 
147
158
  # clean up custom/meta fields. there are not batch operations so we might as well do them here.
@@ -337,7 +348,7 @@ module Agents
337
348
  return ::BigcommerceProductAgent::Mapper.const_get(class_name.to_sym)
338
349
  end
339
350
 
340
- def upsert_product(sku, product, bc_product = nil, is_digital=false)
351
+ def upsert_product(sku, product, bc_product = nil, is_digital=false, search_skus=[])
341
352
  custom_fields_updates = get_mapper(:CustomFieldMapper).map(
342
353
  interpolated['custom_fields_map'],
343
354
  product,
@@ -350,7 +361,10 @@ module Agents
350
361
  sku,
351
362
  product,
352
363
  product_id,
353
- { custom_fields: custom_fields_updates[:upsert] },
364
+ {
365
+ additional_search_terms: search_skus,
366
+ custom_fields: custom_fields_updates[:upsert]
367
+ },
354
368
  is_digital,
355
369
  )
356
370
 
@@ -38,7 +38,7 @@ module BigcommerceProductAgent
38
38
  height: product['height'] ? product['height']['value'] : '0',
39
39
  meta_keywords: self.meta_keywords(product),
40
40
  meta_description: self.meta_description(product) || '',
41
- search_keywords: self.meta_keywords(product).join(','),
41
+ search_keywords: self.get_search_keywords(additional_data.delete(:additional_search_terms), product),
42
42
  is_visible: variant ? false : true,
43
43
  }
44
44
  result[:upc] = product['gtin12'] if product['gtin12']
@@ -182,6 +182,11 @@ module BigcommerceProductAgent
182
182
  end
183
183
  end
184
184
  end
185
+
186
+ # get a list of search keywords for the products
187
+ def self.get_search_keywords(additional_search_terms, product)
188
+ return (self.meta_keywords(product) + additional_search_terms.split(",")).join(",")
189
+ end
185
190
  end
186
191
  end
187
192
  end
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: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Spizziri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler