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)
Refactor: color module & improve error handling 96f024ed74732247d94c6539a4a4e1af4f9f08c4 Sebastian Fricke 2020-05-25 12:21:46
Bug-Fix: Error with fullnumber SKU (price.py) 6bc887ff86628f648eceedebddb1cb6b0b9e15fc Sebastian Fricke 2020-05-06 09:45:06
Bug-Fix: Error with full number SKU 64e6fa1558c1d892fae8e8d6a58bc6351a9edb14 Sebastian Fricke 2020-05-06 09:41:08
Specify the data type of the config a99f6b482fe45bf4aa3c89f276d35e67924dfb3b Sebastian Fricke 2020-05-06 08:59:23
Bug-Fix: Skip external ID check on no result 7a7ba7cee756feccfd836156e192a4eb08d18f2f Sebastian Fricke 2020-05-06 08:57:20
amazon.py: Add additonal amazon product type e8922a4fddb62fc900bb46976eddae6264341528 Sebastian Fricke 2020-05-06 08:54:59
Remove needless bracket at end of string fd588b0c562cc0d0315c3a463cc9dd41f3df2cae Sebastian Fricke 2020-05-04 09:12:01
Add warning for missing standard category c53d5623454e92518e681bfd845bf2e8091a4493 Sebastian Fricke 2020-04-30 07:52:18
Bug-Fix: ',' within standard category field 1bbc9791bf61c8c6d1889f3ba29191d665f85185 Sebastian Fricke 2020-04-30 07:44:40
Bug-Fix: Missing 'n's from Item name b7d5f1d61d0b38646b1b71fc31d55f27ca551851 Sebastian Fricke 2020-04-30 07:43:07
Bug-Fix: Wrong value assignment to zip 7fbe847e16821ddbaf18763d540d3f62a39567e0 Sebastian Fricke 2020-04-30 07:25:08
Fix-Typo: Typo in user prompt for the image upload ed75e2ffc7426217ce6d529994901bd17f22b133 Sebastian Fricke 2020-04-30 06:55:36
Bug-fix: Empty output item upload c7b09d6224024d03e2ac711371091fc46c234bb0 Sebastian Fricke 2020-04-30 06:53:28
Remove encoding from xlsx file intern numbers 798259d898b83395e50f4d855399058c807f0c0c Sebastian Fricke 2020-04-29 13:50:47
Improve coding style and linting d3d1d6de52f0f5530ec200aae082ac0ec99ddd70 Sebastian Fricke 2020-04-29 10:08:21
Remove fixed values for specific item settings 0f2452a1bb953efcbb797c5feeb2b8f35617f537 Sebastian Fricke 2020-04-29 08:38:52
Remove fixed fba values from upload 758ca263cf88343c55af70b1e7824c76d485d7f2 Sebastian Fricke 2020-04-29 08:32:09
Remove market assign & availibilty settings fdf971d45706f8c75d9a7ea7e949193c45620051 Sebastian Fricke 2020-04-29 07:31:36
Remove manual upload of extern id & export files 66d60bc9243173f256b01071f203849edf43546d Sebastian Fricke 2020-04-28 13:55:27
Bug Fix: product-import.py Empty TK root window 0b087f8a7902523b2495c936a6e09447a93a6cb5 Sebastian Fricke 2020-04-28 09:41:04
Commit 96f024ed74732247d94c6539a4a4e1af4f9f08c4 - Refactor: color module & improve error handling
Improve error handling messages, fix coding style issues, add
documentation.

Signed-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>
Author: Sebastian Fricke
Author date (UTC): 2020-05-25 12:21
Committer name: Sebastian Fricke
Committer date (UTC): 2020-05-25 12:21
Parent(s): 6bc887ff86628f648eceedebddb1cb6b0b9e15fc
Signing key:
Tree: 4928ca4d7d1afc90ebd8249782b1720a7f712e8d
File Lines added Lines deleted
packages/color.py 73 43
packages/gui/category_chooser.py 1 1
File packages/color.py changed (mode: 100644) (index 4176e08..f62715e)
1 """
2 Author: Sebastian Fricke
3 License: GPL v3
4 Company: Panasiam
5
6 Process colors unknown for plentymarkets, by providing a list of similar
7 values and uploading new values.
8 """
1 9 import csv import csv
2 10 import re import re
3 from packages import barcode
4
5
6 def missingColor(flatfile, attributefile):
7 # check the attribute export from PlentyMarkets for similar color names
8 # _____________________________
11 import sys
12 from packages import barcode, error
13
14
15 def missing_color(flatfile, attributefile):
16 """
17 Detect any color names that are not found on PlentyMarkets.
18 Generate a list of similar color names and find the highest
19 position number of the color attributes.
20
21 Parameters:
22 flatfile [csv] - Amazon Flatfile format of product data
23 attributefile [csv] - Plentymarkets Export with the values:
24 * AttributeValue.position
25 * AttributeValue.backendName
26
27 Return:
28 missing_colors [dict] - mapped similar names and highest position
29 for each new color
30 """
9 31 color_list = set() color_list = set()
10 32 missing_colors = dict() missing_colors = dict()
11 # Open the attribute file to get all color names
12 33 # Get the highest position number # Get the highest position number
13 34 highest_number = int(0) highest_number = int(0)
14 35
15 with open(attributefile['path'], mode = 'r', encoding=attributefile['encoding']) as item:
36 with open(attributefile['path'], mode='r',
37 encoding=attributefile['encoding']) as item:
16 38 reader = csv.DictReader(item, delimiter=';') reader = csv.DictReader(item, delimiter=';')
17 39
18 40 for row in reader: for row in reader:
19 41 try: try:
20 if(int(row['AttributeValue.position']) > highest_number):
42 if int(row['AttributeValue.position']) > highest_number:
21 43 highest_number = int(row['AttributeValue.position']) highest_number = int(row['AttributeValue.position'])
22 except KeyError as err:
23 print("ERROR @ reading attribute file: {0}".format(err))
24 if('AttributeValue.backendName' in [*row]):
25 44 color_list.add(row['AttributeValue.backendName']) color_list.add(row['AttributeValue.backendName'])
26 else:
27 print("Wrong Columns in the attribute file!\n{0}\n".format(",".join([*row])))
45 except KeyError as err:
46 error.errorPrint(msg="invalid attribute file", err=err,
47 linenumber=sys.exc_info()[2].tb_lineno)
28 48
29 missing_colors_columns = ['color_name', 'similar_names', 'highest-position']
49 missing_colors_columns = ['color_name', 'similar_names',
50 'highest-position']
30 51
31 52 # Open the flatfile to check which names are not in the color_list # Open the flatfile to check which names are not in the color_list
32 with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item:
33 reader = csv.DictReader(item, delimiter = ';')
53 with open(flatfile['path'], mode='r',
54 encoding=flatfile['encoding']) as item:
55 reader = csv.DictReader(item, delimiter=';')
34 56
35 57 color_set = set() color_set = set()
36 for num, row in enumerate( reader ):
58 for num, row in enumerate(reader):
37 59 color_name = row['color_name'] color_name = row['color_name']
38 if(not( color_name in color_list ) and not(color_name in color_set)):
60 if not color_name in color_list and not color_name in color_set:
39 61 color_set.add(color_name) color_set.add(color_name)
40 62 values = [color_name, [], highest_number] values = [color_name, [], highest_number]
41 missing_colors[str(num)] = dict(zip(missing_colors_columns, values))
63 missing_colors[str(num)] =\
64 dict(zip(missing_colors_columns, values))
42 65
43 66 # Open the attribute file to check for similar names to the missing ones # Open the attribute file to check for similar names to the missing ones
44 with open(attributefile['path'], mode = 'r', encoding=attributefile['encoding']) as item:
45 reader = csv.DictReader(item, delimiter = ';')
67 with open(attributefile['path'], mode='r',
68 encoding=attributefile['encoding']) as item:
69 reader = csv.DictReader(item, delimiter=';')
46 70
47 71 for row in reader: for row in reader:
48 72 for color in missing_colors: for color in missing_colors:
49 73 try: try:
50 if(re.search( missing_colors[color]['color_name'][1:], row['AttributeValue.backendName'] )):
51 missing_colors[color]['similar_names'].append(row['AttributeValue.backendName'])
74 if(re.search(missing_colors[color]['color_name'][1:],
75 row['AttributeValue.backendName'])):
76 missing_colors[color]['similar_names'].append(
77 row['AttributeValue.backendName'])
52 78 except KeyError as err: except KeyError as err:
53 print("ERROR @ similar name search: {0}".format(err))
54
55 '''
56 for row in missing_colors:
57 print("COLOR: {0}\n".format( missing_colors[row]['color_name'] ))
58 for name in missing_colors[row]['similar_names']:
59 print("similar to {0}: {1}".format(missing_colors[row]['color_name'], name))
60 '''
79 error.errorPrint(msg="invalid attribute file", err=err,
80 linenumber=sys.exc_info()[2].tb_lineno)
81
61 82 return missing_colors return missing_colors
62 83
63 84 def create_attributesync(color_dict, path): def create_attributesync(color_dict, path):
64 column_names = ['Attribute.id','AttributeValue.backendName','AttributeValue.position','AttributeValueName.name']
65
66 Data = {}
85 """
86 Create a Elastic Sync (import) file for Plentymarkets.
87
88 Parameters:
89 color_dict [dict] - Combination of a new color name and
90 it's position within the attributes
91 path [str] - Path of the Upload folder
92 """
93 column_names = ['Attribute.id', 'AttributeValue.backendName',
94 'AttributeValue.position', 'AttributeValueName.name']
95
96 data = {}
67 97 values = [] values = []
68 98
69 99 for index, row in enumerate(color_dict): for index, row in enumerate(color_dict):
70 try:
71 values = ['4', color_dict[row]['color_name'], int(float(color_dict[row]['highest-position'])) + int(index + 1), color_dict[row]['color_name']]
72 except KeyError as err:
73 print(color_dict[row])
74 print("ERROR @ attribute sync creation: {0}".format(err))
75
76 Data[color_dict[row]['color_name']] = dict(zip(column_names, values))
100 values = [
101 '4', color_dict[row]['color_name'],
102 int(float(color_dict[row]['highest-position'])) + int(index + 1),
103 color_dict[row]['color_name']
104 ]
77 105
78 barcode.writeCSV(dataobject=Data, name="Color_Sync", columns=column_names, upload_path=path, item="")
106 data[color_dict[row]['color_name']] = dict(zip(column_names, values))
79 107
108 barcode.writeCSV(dataobject=data, name="Color_Sync",
109 columns=column_names, upload_path=path, item="")
File packages/gui/category_chooser.py changed (mode: 100644) (index 1c1c52c..2c7cdee)
... ... class CategoryChooser(tkinter.Tk):
409 409
410 410 def checkColors(self, flatfile, attributefile): def checkColors(self, flatfile, attributefile):
411 411 attributefile = item_upload.checkEncoding(attributefile) attributefile = item_upload.checkEncoding(attributefile)
412 self.missingcolors = clr.missingColor(flatfile, attributefile)
412 self.missingcolors = clr.missing_color(flatfile, attributefile)
413 413
414 414 colorlist = [] colorlist = []
415 415
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