question

dhanaraj avatar image
dhanaraj asked Dan answered

Categories list and modifier list is not added for the item using inventory connector.

I have create a item using Inventory connector. But categories lis and modifier list can't uploaded for the item.

	item.setCategories(categoryList);
	item.setCode(et_code.getText().toString());
	item.setSku(et_sku.getText().toString());
	item.setPrice(Long.valueOf(ed_price.getText().toString()));
	item.setPriceType(PriceType.FIXED);
	item.setModifierGroups(modifierGroupList);
	item.setTaxRates(taxRates);
	item.setTags(tagList);
	item.setCost(Long.valueOf(et_itemcost.getText().toString()));
	item.setIsRevenue(!chkbx_non_revenue_item.isChecked());
	item.setStockCount(Long.valueOf(et_qty.getText().toString()));
then adding the item using inventoryConnector.createItem(item)


inventoryConnector.createItem(new_item);
InventoryModifiers
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

chanel avatar image chanel commented ·

Are you getting a particular error? How are you adding a category?

0 Likes 0 ·
Dan avatar image Dan ♦ commented ·

Please provide a minimal, complete, verifiable example https://stackoverflow.com/help/mcve

0 Likes 0 ·
dhanaraj avatar image dhanaraj Dan ♦ commented ·

@Dan I have added the code sample in the question. When create the item using inventoryConnector.createItem(item) But result json shows null in categories,modifier

0 Likes 0 ·
Dan avatar image
Dan answered
The categories and modifiers have to be added (and removed) with other InventoryConnector methods.

Something along the lines of:
// instantiate at inventory connector        
// create a new item        
// build a list of categories from the merchant's categories        
// build a list of modifier groups from the merchant's         
inventoryConnector.createItem(myItem);        
for (Category category : myCategories) {            
  inventoryConnector.addItemToCategory(category);        
}        
for (ModifierGroup modifierGroup : myModifierGroups) {          
  inventoryConnector.assignModifierGroupToItem(modifierGroup);        
}
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dhanaraj avatar image
dhanaraj answered dhanaraj published
item.setName(et_item_name.getText().toString());<br>item.setCategories(categoryList);<br>item.setCode(et_code.getText().toString());<br>item.setSku(et_sku.getText().toString());<br>item.setPrice(Long.valueOf(ed_price.getText().toString()));<br>item.setPriceType(PriceType.FIXED);<br>item.setModifierGroups(modifierGroupList);<br>item.setTaxRates(taxRates);<br>item.setTags(tagList);<br>item.setCost(Long.valueOf(et_itemcost.getText().toString()));<br>item.setIsRevenue(!chkbx_non_revenue_item.isChecked());<br>item.setStockCount(Long.valueOf(et_qty.getText().toString()));




Here I passes the value of categories,modifers and tax in list. then create the item using inventory connector. Result set I couldn't seen any of the list values are added.

inventoryConnector.createItem(item); 



10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community