// Sync categories : download.
Categorie[] cats = externalsales.getCategories();
for (Categorie categorie : cats) {
CategoryInfo addCategory = new CategoryInfo(categorie.getId(), externalsales.encodeStringISO(categorie.getName()), null);
try {
dlintegration.syncCategory(addCategory);
} catch (BasicException be) {
// be.printStackTrace();
}
notToSync.put(categorie.getName(),categorie.getId());
}
// UPLOAD CATEGORIES NOT USED YET (should be on creation only with ID sync !)
SentenceList localCatsList = dlsales.getCategoriesList();
List<CategoryInfo> localCats = localCatsList.list();
for (CategoryInfo localCat : localCats) {
if (dlintegration.getCategoryCount(localCat.getName())==0.0){
continue;
}
if (notToSync.containsKey(localCat.getName())) {
continue;
}
Categorie category = new Categorie();
category.setId(localCat.getID());
category.setName(localCat.getName());
category.setImage("");
category.setDescription(localCat.getName());
category.setParentcat("");
category.setNumberofproducts("");
category.setProducts_per_row("1");
category.setFullimage("");
category.setCategory_publish("Y");
category.setCategory_browsepage("");
category.setCategory_flypage("");
externalsales.addCategory(category);
}
cats = externalsales.getCategories();
HashMap<String, String> catList = new HashMap<String, String>();
HashMap<String, String> catListRev = new HashMap<String, String>();
for (Categorie cat: cats) {
Iterator<CategoryInfo> it = localCats.iterator();
while (it.hasNext()) {
CategoryInfo ci = it.next();
if (ci.getName().equalsIgnoreCase(cat.getName())) {
catList.put(ci.getID() , cat.getId());
catListRev.put(cat.getId(), ci.getID());
// localCats.remove(ci);
break;
}
}