Excel Import File
For single product's that are associated with a grouped product, you can now specify the unique SKU of the parent grouped product instead of the numeric ID. This keeps everything dynamic.
Example:
NIKE-GSERIES instead of number 18
The following variable was changed from int to string.
string parentGroupedProductId = Convert.ToString(worksheet.Cells[iRow, GetColumnIndex(properties, "ParentGroupedProductId")].Value);
Now in your excel import file you can specify the unique SKU of the parent group instead of it's ID.
The following code checks the parentGroupedProductId from the excel file for 0 (no parent) or the parents unique SKU.
//does this record have a parent group specified? 0 means no parent group, while anything else is a unique SKU
if (parentGroupedProductId != "0")
{
//since the parent group SKU was specified let's get the parent group ID
//example of unique SKU for parent group: NIKE-GSERIES-GROUP (I like to append -GROUP at the end)
var parentGroupProduct = _productService.GetProductBySku(parentGroupedProductId);
//associate the current product with the following parent group product
product.ParentGroupedProductId = parentGroupProduct.Id;
}
else
{
//do not associate this product with any group product
product.ParentGroupedProductId = 0;
}
I have to modify the export code to specify the unique SKU of the parent instead of it's parent ID.
Now the import and export process for single products associated with a group is completely dynamic instead of using hard coded numeric parent id's. This works great for new products and updating of existing products.
Any problems let me know.
SAMPLE EXCEL IMPORT FIELDS
ProductTypeID - ParentGroupProductID - SKU
10 (Grouped Product) / 0 / NIKE-GSERIES-GROUP
5 (Single Product) / NIKE-GSERIES-GROUP / NIKE-GSERIES-RED
5 (Single Product) / NIKE-GSERIES-GROUP / NIKE-GSERIES-BLUE