initBasti / Amazon2PlentySync (public) (License: GPLv3) (since 2019-01-27) (hash sha1)
Transfer your data from you Amazon Flatfile spreadsheet over to the Plentymarkets system. How to is included in the readme
List of commits:
Subject Hash Author Date (UTC)
similar attribute search regardless of the parent 4bb0970408d78d25264d479428fe8c3389483215 Sebastian Fricke 2020-04-23 09:28:19
Fix marking dropdown bug 0d1695083d2b4e49fd364a36a7ef3c92a192d62f Sebastian Fricke 2020-04-23 09:26:46
update desktop specific build script for windows 8a6536d6173f7383022fab92f234ab25fc81204b Sebastian Fricke 2020-04-22 10:15:05
Refactor config handling a9be950a4e8d97fa97c7e9caff33fcbb1f476d9d Sebastian Fricke 2020-04-22 10:11:57
Fix gui/category_chooser: file change bug 9879e65c9aad9b1feb05b6121a0e33c129a8beb5 Sebastian Fricke 2020-04-22 10:09:36
update .gitignore 6c7628af605a72ced1e146c27da8639225ab9c6c Sebastian Fricke 2020-04-22 10:08:47
Fix error.py: Fix colorful messages on windows 31f0b106c7aee1962bba3efb5758f647170eceff Sebastian Fricke 2020-04-22 10:07:30
Enhanced error output to extra module dda37a22d21db1af6330fd62395682b91f46f5ec Sebastian Fricke 2020-01-27 10:56:00
Introduction infoPrint, removed unnecessary parameter 98b6779f95fcf6d3350f64e7d2a8151932415458 Sebastian Fricke 2020-01-16 14:27:15
Add Cdiscount price & coding style review 7c5451b067760100904aed947b2ba484ab9c9e45 Sebastian Fricke 2020-01-16 14:25:15
coding style, naming conventions & uninitialized 218378ca191510dc2092108a87e63ff83b4c6b31 Sebastian Fricke 2020-01-16 13:58:24
coding style & cleanup image upload module 04ac13fb764baecd1a419cbffcd9696a3ff5b680 Sebastian Fricke 2020-01-16 13:56:07
coding style improvements and colorful error msg 401db811c0edd62b14c7a0a29e2c1f6d2791774c Sebastian Fricke 2020-01-16 13:54:25
code cleanup and coding style category.py b1e41b45fe405d3826a9b6e452fb9e2f9f6697bf Sebastian Fricke 2020-01-16 10:43:44
Added the category config to the gitignore file b8b522d9ade4b59b5d0a0bd4f9b7c79e8db334c6 Sebastian Fricke 2020-01-15 14:56:06
Removed log function for category_config(not needed) c8ca8a3b6b968f1835697073e7d5fe1ea70b15ba Sebastian Fricke 2020-01-15 14:54:15
Added category_config functionality 7bd8256398b4af5c1feb3033d74cd9f29b047edc Sebastian Fricke 2020-01-15 14:53:20
improved error handling & adjusted names to naming convention cfcd91090a2598c6c51576bcdd53e03ab6c2f59b Sebastian Fricke 2020-01-15 14:47:42
Refactor CategoryChooser 562e6657c6fef89d0584731e54325cec013268a7 Sebastian Fricke 2020-01-15 14:42:11
Add category_config location to the script config 8698e4a99d63b06fde5c39787fc7d6f7400b9f47 Sebastian Fricke 2020-01-15 14:29:47
Commit 4bb0970408d78d25264d479428fe8c3389483215 - similar attribute search regardless of the parent
Change the default behaviour of "getAttributes" to always include the
color attribute.
"findSimilarAttr", now takes an additional parameter as a list of column
names for the creation of sets, this makes it more extendable for future
additions.
Add function description to getAttributes and findSimilarAttr.
Add a additional Exception case to "getProperties" to check for a
KeyError.
Author: Sebastian Fricke
Author date (UTC): 2020-04-23 09:28
Committer name: Sebastian Fricke
Committer date (UTC): 2020-04-23 09:28
Parent(s): 0d1695083d2b4e49fd364a36a7ef3c92a192d62f
Signing key:
Tree: 81c107f9ede4fbe9c014cf0be8dd064447dce1bc
File Lines added Lines deleted
packages/item_upload.py 49 19
File packages/item_upload.py changed (mode: 100644) (index 381919e..c5bcfb3)
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
48 48 # Get sets of all colors and sizes for each parent # Get sets of all colors and sizes for each parent
49 49 # to find if there are some with only one attribute value for all childs # to find if there are some with only one attribute value for all childs
50 50 color_size_sets = {} color_size_sets = {}
51 color_size_sets = findSimilarAttr(flatfile)
51 color_size_sets = findSimilarAttr(flatfile, ['size_name'])
52 52
53 53 package_properties = getProperties(flatfile) package_properties = getProperties(flatfile)
54 54 group_parent = '' group_parent = ''
 
... ... def getProperties(flatfile):
310 310 properties['width'] = int(float(row['package_width'])) properties['width'] = int(float(row['package_width']))
311 311 properties['weight'] = int(float(row['package_weight'])) properties['weight'] = int(float(row['package_weight']))
312 312 except ValueError as err: except ValueError as err:
313 error.errorPrint("Parent has no package measurements", err,
314 sys.exc_info()[2].tb_lineno)
313 error.errorPrint(
314 msg="Parent has no package measurements", err=err,
315 linenumber=sys.exc_info()[2].tb_lineno)
315 316 sys.exit() sys.exit()
317 except KeyError as err:
318 msg = str(f"getProperties key: {err} not found")
319 error.errorPrint(msg=msg, err='',
320 linenumber=sys.exc_info()[2].tb_lineno)
316 321 except Exception as err: except Exception as err:
317 error.errorPrint("getProperties setting values failed", err,
318 sys.exc_info()[2].tb_lineno)
322 error.errorPrint(
323 msg="getProperties setting values failed", err=err,
324 linenumber=sys.exc_info()[2].tb_lineno)
319 325
320 326 return properties return properties
321 327
322 328 def getAttributes(dataset, sets): def getAttributes(dataset, sets):
329 """
330 Parameter:
331 dataset [Dictionary] => row of the flatfile as dictionary
332 sets [Dictionary] => attribute sets mapped to parent sku's by
333 "findSimilarAttr()"
334
335 Description:
336 Build the attribute string of the color and size
337 Elastic Sync upload format:
338 {attr. name}:{value};{attr.2 name}:{value}
339
340 Return:
341 output_string
342 """
323 343
324 344 output_string = '' output_string = ''
325 345 try: try:
326 346 if dataset['parent_sku'] in list(sets.keys()): if dataset['parent_sku'] in list(sets.keys()):
327 if len(sets[dataset['parent_sku']]['color']) > 1:
328 output_string = 'color_name:' + dataset['color_name']
347 output_string = 'color_name:' + dataset['color_name']
329 348 else: else:
330 349 print("{0} not found in {1}" print("{0} not found in {1}"
331 350 .format(dataset['parent_sku'], ','.join(list(sets.keys())))) .format(dataset['parent_sku'], ','.join(list(sets.keys()))))
 
... ... def getAttributes(dataset, sets):
333 352 error.errorPrint("Adding of color attribute failed", err, error.errorPrint("Adding of color attribute failed", err,
334 353 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
335 354 try: try:
336 if len(sets[dataset['parent_sku']]['size']) > 1:
355 if len(sets[dataset['parent_sku']]['size_name']) > 1:
337 356 if not output_string: if not output_string:
338 357 output_string = 'size_name:' + dataset['size_name'] output_string = 'size_name:' + dataset['size_name']
339 358 else: else:
 
... ... def getAttributes(dataset, sets):
343 362 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
344 363 return output_string return output_string
345 364
346 def findSimilarAttr(flatfile):
365 def findSimilarAttr(flatfile, attribute):
366 """
367 Parameter:
368 flatfile [Dictionary] => Dictionary with a path and a
369 encoding string
370 attribute [List of Strings] => Names of the columns in the flatfile
371
372 Description:
373 Detect the amount different elements of a attribute within a
374 group of variations of the same parent variation.
375
376 Return:
377 data => Dictionary of parent sku's mapped to
378 sets of different values
379 """
347 380
348 381 data = {} data = {}
349 382
 
... ... def findSimilarAttr(flatfile):
351 384 reader = csv.DictReader(item, delimiter=";") reader = csv.DictReader(item, delimiter=";")
352 385
353 386 for row in reader: for row in reader:
354 # If it is a parent create a new dictionary with 2 sets for color and size
355 if row['parent_child'].lower() == 'parent':
356 color = set()
357 size = set()
358 data[row['item_sku']] = {'color':color, 'size':size}
359 # If it is a child search through the data dictionary for a match
387 p_sku = row['parent_sku']
388 if p_sku and p_sku not in data.keys():
389 data[p_sku] = dict()
390 for attr in attribute:
391 data[p_sku][attr] = set()
360 392 if row['parent_child'] == 'child': if row['parent_child'] == 'child':
361 for line in data:
362 if row['parent_sku'] == line:
363 data[row['parent_sku']]['color'].add(row['color_name'])
364 data[row['parent_sku']]['size'].add(row['size_name'])
393 for attr in attribute:
394 data[p_sku][attr].add(row[attr])
365 395 return data return data
366 396
367 397 def sortProducts(dataset): def sortProducts(dataset):
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/initBasti/Amazon2PlentySync

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/initBasti/Amazon2PlentySync

Clone this repository using git:
git clone git://git.rocketgit.com/user/initBasti/Amazon2PlentySync

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main