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)
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
Bug Fix: product-import.py Empty TK root window 0b087f8a7902523b2495c936a6e09447a93a6cb5 Sebastian Fricke 2020-04-28 09:41:04
Add ignore file for silver searcher tool 87a1b335af1f88c10ad12e5b8f59f8207c58aaec Sebastian Fricke 2020-04-28 09:25:54
add tests folder pycache to gitignore 9d7989d1658d3dffd7eb00e9411af3dec6c85563 Sebastian Fricke 2020-04-27 12:55:24
Unit test for find_price function c19fa28ad9bf0dd1b5361e871dc498f6704cb196 Sebastian Fricke 2020-04-27 12:53:20
Remove price calculation from script d852cb3ef648336ed94daeaaa220721e6055dd7c Sebastian Fricke 2020-04-27 12:50:52
Function description priceUpload 2c5735f4f4c79607f55c77b1359aa5984d1e6699 Sebastian Fricke 2020-04-23 09:34:30
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
Commit 758ca263cf88343c55af70b1e7824c76d485d7f2 - Remove fixed fba values from upload
Refactor function to get_producttype_id, which uses pandas instead of
csv for csv reading, as preparation for the future.
Improved error checking and renamed module to amazon.
Author: Sebastian Fricke
Author date (UTC): 2020-04-29 08:32
Committer name: Sebastian Fricke
Committer date (UTC): 2020-04-29 08:32
Parent(s): fdf971d45706f8c75d9a7ea7e949193c45620051
Signing key:
Tree: 30d2ad0ce7bf2259c681e44258086aa51fd63b12
File Lines added Lines deleted
packages/amazon.py 56 46
packages/item_upload.py 5 17
product_import.py 6 6
File packages/amazon.py renamed from packages/amazon_data_upload.py (similarity 56%) (mode: 100644) (index 249c228..3a5f2ad)
1 1 import csv import csv
2 import pandas
2 3 from os.path import isfile from os.path import isfile
3 4 from packages import barcode from packages import barcode
4 5 try: try:
 
... ... def amazonSkuUpload(flatfile):
29 30 return Data return Data
30 31
31 32
32 def amazonDataUpload(flatfile):
33
34 column_names = ['ItemAmazonProductType',
35 'ItemAmazonFBA',
36 'ItemShippingWithAmazonFBA']
37
38 Data = SortedDict()
39
40 with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item:
41 reader = csv.DictReader(item, delimiter=";")
42
43 type_id = {
44 'accessory': 28,
45 'shirt': 13,
46 'pants': 15,
47 'dress': 18,
48 'outerwear': 21,
49 'bag': 27,
50 'furnitureanddecor': 4,
51 'bedandbath': 3,
52 'swimwear': 30
53 }
54
55 values = ''
56 product_type = ''
57
58 for row in reader:
59 # go through the variations until the values are filled
60 if(row['feed_product_type'].lower() in [*type_id]):
61 for key in type_id:
62 if(row['feed_product_type'].lower() == key):
63 product_type = type_id[key]
64 else:
65 print("ERROR @ product type in AmazonData: {0} not in {1}"
66 .format(row['feed_product_type'],
67 ",".join([*type_id])))
68
69 if(not(product_type) and not(row['feed_product_type'])):
70 raise barcode.EmptyFieldWarning('product_type')
71
72 values = [product_type, '1', '1']
73
74 Data[row['item_sku']] = SortedDict(zip(column_names, values))
75
76 return Data
77
33 def get_producttype_id(source, sku):
34 """
35 Parameter:
36 source [Dictionary] => dictionary of the flatfile
37 with path and encoding
38 sku [String] => String of the product sku
39
40 Description:
41 Search for a matching term in mapping list of valid
42 amazon producttype names and their ID.
43
44 Return:
45 [Integer]
46 value from type_id on success
47 0 on failure
48 """
49 type_id = {
50 'accessory': 28,
51 'shirt': 13,
52 'pants': 15,
53 'dress': 18,
54 'outerwear': 21,
55 'bag': 27,
56 'furnitureanddecor': 4,
57 'bedandbath': 3,
58 'swimwear': 30
59 }
60
61 df = pandas.read_csv(source['path'],
62 sep=';',
63 encoding=source['encoding'])
64
65 sku_df = df[df['item_sku'] == sku]
66 if len(sku_df.index) == 0:
67 error.warnPrint(msg=str(f"{sku} not found in flatfile"), err='',
68 linenumber=inspect.currentframe().f_back.f_lineno)
69 return 0
70
71 if sku_df.filter(like='product_type', axis=1).empty:
72 msg=str("wrong header: ..{0} requires a product_type column"
73 .format(source['path'][-21:]))
74 error.warnPrint(
75 msg=msg, err='',
76 linenumber=inspect.currentframe().f_back.f_lineno)
77 return 0
78
79 value = sku_df.filter(like='product_type', axis=1)\
80 .to_string(na_rep='', index=False, header=False)\
81 .lower().strip(' ')
82
83 if not value:
84 return 0
85
86 if value in type_id.keys():
87 return type_id[value]
78 88
79 89 def featureUpload(flatfile, features, folder, filename): def featureUpload(flatfile, features, folder, filename):
80 90
File packages/item_upload.py changed (mode: 100644) (index a9c9d5b..b195ce5)
... ... import collections
5 5 import inspect import inspect
6 6 import chardet import chardet
7 7 import os import os
8 from packages import barcode, amazon_data_upload, price, error
8 from packages import barcode, amazon, price, error
9 9
10 10
11 11 class WrongEncodingException(Exception): class WrongEncodingException(Exception):
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
27 27 'EAN_Barcode', 'FNSKU_Barcode', 'EAN_Barcode', 'FNSKU_Barcode',
28 28 'marketid', 'accountid', 'marketid', 'accountid',
29 29 'amazon_sku', 'amazon_parentsku', 'amazon_sku', 'amazon_parentsku',
30 'amazon-producttype', 'fba-enabled', 'fba-shipping',
30 'amazon-producttype',
31 31 'price', 'ASIN-countrycode', 'ASIN-type', 'ASIN-value', 'price', 'ASIN-countrycode', 'ASIN-type', 'ASIN-value',
32 32 'Item-Flag-1' 'Item-Flag-1'
33 33 ] ]
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
113 113 '', '', # barcode '', '', # barcode
114 114 '', '', # market & accout id amazonsku '', '', # market & accout id amazonsku
115 115 '', '', # sku & parentsku amazonsku '', '', # sku & parentsku amazonsku
116 '', '', '', # producttype & fba amazon
116 amazon.get_producttype_id(source=flatfile,
117 sku=row['item_sku']),
117 118 item_price, # prices item_price, # prices
118 119 '', '', '', #asin '', '', '', #asin
119 120 input_data['marking'] input_data['marking']
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
160 161 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
161 162
162 163 # Include the amazonsku # Include the amazonsku
163 sku_data = amazon_data_upload.amazonSkuUpload(flatfile)
164 sku_data = amazon.amazonSkuUpload(flatfile)
164 165
165 166 for row in sku_data: for row in sku_data:
166 167 try: try:
 
... ... def itemUpload(flatfile, intern, stocklist, folder, input_data, filename):
173 174 error.errorPrint("SKU part for "+row, err, error.errorPrint("SKU part for "+row, err,
174 175 sys.exc_info()[2].tb_lineno) sys.exc_info()[2].tb_lineno)
175 176
176 # Include the amazonsku
177 ama_data = amazon_data_upload.amazonDataUpload(flatfile)
178
179 for row in ama_data:
180 try:
181 if row in list(data.keys()):
182 data[row]['amazon-producttype'] = ama_data[row]['ItemAmazonProductType']
183 data[row]['fba-enabled'] = ama_data[row]['ItemAmazonFBA']
184 data[row]['fba-shipping'] = ama_data[row]['ItemShippingWithAmazonFBA']
185 except Exception as err:
186 error.errorPrint("Amazondata part for "+row, err,
187 sys.exc_info()[2].tb_lineno)
188
189 177 # Sort the dictionary to make sure that the parents are the first variant of each item # Sort the dictionary to make sure that the parents are the first variant of each item
190 178 sorted_data = sortProducts(data) sorted_data = sortProducts(data)
191 179
File product_import.py changed (mode: 100644) (index 5256fe6..13f165e)
1 import tkinter
2 from tkinter.filedialog import askopenfilename
3 import sys
4 import platform
5 import os
6 1 import time import time
7 2 import ntpath import ntpath
8 3 import re import re
9 4 import datetime import datetime
5 import tkinter
6 from tkinter.filedialog import askopenfilename
7 import os
8 import sys
9 import platform
10 10 try: try:
11 11 import configparser import configparser
12 12 except ImportError: except ImportError:
 
... ... from packages.item_upload import (
16 16 itemUpload, WrongEncodingException, checkEncoding, itemUpload, WrongEncodingException, checkEncoding,
17 17 checkFlatfile, itemPropertyUpload) checkFlatfile, itemPropertyUpload)
18 18 from packages.barcode import EmptyFieldWarning from packages.barcode import EmptyFieldWarning
19 from packages.amazon_data_upload import featureUpload
19 from packages.amazon import featureUpload
20 20 from packages.log_files import ( from packages.log_files import (
21 21 fileNotFoundLog, keyErrorLog, wrongEncodingLog, fileNotFoundLog, keyErrorLog, wrongEncodingLog,
22 22 unboundLocalLog, emptyFieldWarningLog) unboundLocalLog, emptyFieldWarningLog)
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