void clicked()
{
EcoResProductMaster ecoResProductMaster;
EcoResProductIdentifier ecoResProductIdentifier;
EcoResProductDimensionGroupProduct ecoResProductDimensionGroupProduct;
EcoResProductMasterModelingPolicy ecoResProductMasterModelingPolicy;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResConfiguration ecoResConfiguration;
EcoResProductMasterConfiguration ecoResProductMasterConfiguration;
EcoResColor ecoResColor;
EcoResProductMasterColor ecoResProductMasterColor;
EcoResSize ecoResSize;
EcoResProductMasterSize ecoResProductMasterSize;
EcoResStyle ecoResStyle;
EcoResProductMasterStyle ecoResProductMasterStyle;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
EcoResProductVariantColor ecoResProductVariantColor;
EcoResProductVariantSize ecoResProductVariantSize;
EcoResProductVariantStyle ecoResProductVariantStyle;
InventTable inventTable;
InventTableModule inventTableModule;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventDim inventDim;
InventDimCombination inventDimCombination;
NumberSequenceTable numberSequenceTable;
EcoResProductDisplayProductNumber displayProductNumber;
MerchandisingTable merchant;
merchant = MerchandisingTable_ds.getFirst(1);
try
{
while(merchant.RecId != 0)
{
//ProductMaster
ecoResProductMaster.clear();
ecoResProductMaster.initValue();
numberSequenceTable = EcoResProductParameters::numRefProductNumber().numberSequenceTable();
displayProductNumber = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
ecoResProductMaster.ProductType = EcoResProductType::Item;
ecoResProductMaster.DisplayProductNumber = displayProductNumber;
ecoResProductMaster.SearchName = merchant.Styling;
ecoResProductMaster.Brand = merchant.Brand;
ecoResProductMaster.Styling = merchant.Styling;
ecoResProductMaster.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::PredefinedVariants;
if (ecoResProductMaster.validateWrite())
{
ecoResProductMaster.insert();
ecoResProductIdentifier.clear();
ecoResProductIdentifier.initValue();
ecoResProductIdentifier.ProductNumber = ecoResProductMaster.DisplayProductNumber;
ecoResProductIdentifier.Product = ecoResProductMaster.RecId;
ecoResProductIdentifier.insert();
//Product dimension group
ecoResProductDimensionGroupProduct.clear();
ecoResProductDimensionGroupProduct.initValue();
ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(merchant.EcoResProductDimensionGroupName).RecId;
if (ecoResProductDimensionGroupProduct.validateWrite())
{
ecoResProductDimensionGroupProduct.insert();
}
//Storage dimension group
ecoResStorageDimensionGroupProduct.clear();
ecoResStorageDimensionGroupProduct.initValue();
ecoResStorageDimensionGroupProduct.Product = ecoResProductMaster.RecId;
ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(merchant.StorageDimensionGrpName).RecId;
if (ecoResStorageDimensionGroupProduct.validateWrite())
{
ecoResStorageDimensionGroupProduct.insert();
}
//Tracking dimension group
ecoResTrackingDimensionGroupProduct.clear();
ecoResTrackingDimensionGroupProduct.initValue();
ecoResTrackingDimensionGroupProduct.Product = ecoResProductMaster.RecId;
ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(merchant.EcoResTrackingDimensionGrpName).RecId;
if (ecoResTrackingDimensionGroupProduct.validateWrite())
{
ecoResTrackingDimensionGroupProduct.insert();
}
//Product modeling policy
ecoResProductMasterModelingPolicy.clear();
ecoResProductMasterModelingPolicy.initValue();
ecoResProductMasterModelingPolicy.ProductMaster = ecoResProductMaster.RecId;
if (ecoResProductMasterModelingPolicy.validateWrite())
{
ecoResProductMasterModelingPolicy.insert();
}
//Product translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductMaster.Product, ecoResProductMaster.Brand);
//Color
ecoResColor = EcoResColor::findByName(merchant.Color);
if (!ecoResColor)
{
ecoResColor.clear();
ecoResColor.initValue();
ecoResColor.Name = merchant.Color;
ecoResColor.insert();
}
//Color assigned to product master
ecoResProductMasterColor.clear();
ecoResProductMasterColor.initValue();
ecoResProductMasterColor.Color = ecoResColor.RecId;
ecoResProductMasterColor.ColorProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventColorId));
ecoResProductMasterColor.ColorProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterColor.insert();
//Style
ecoResStyle = EcoResStyle::findByName(merchant.StyleName);
if (!ecoResStyle)
{
ecoResStyle.clear();
ecoResStyle.initValue();
ecoResStyle.Name = merchant.StyleName;
ecoResStyle.insert();
}
//Style assigned to product master
ecoResProductMasterStyle.clear();
ecoResProductMasterStyle.initValue();
ecoResProductMasterStyle.Style = ecoResStyle.RecId;
ecoResProductMasterStyle.StyleProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventStyleId));
ecoResProductMasterStyle.StyleProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterStyle.insert();
//Size
ecoResSize = EcoResSize::findByName(merchant.Size);
if (!ecoResSize)
{
ecoResSize.clear();
ecoResSize.initValue();
ecoResSize.Name = merchant.Size;
ecoResSize.insert();
}
//Size assigned to product master
ecoResProductMasterSize.clear();
ecoResProductMasterSize.initValue();
ecoResProductMasterSize.Size = ecoResSize.RecId;
ecoResProductMasterSize.SizeProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventSizeId));
ecoResProductMasterSize.SizeProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterSize.insert();
//Product variant
ecoResDistinctProductVariant.clear();
ecoResDistinctProductVariant.initValue();
ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
ecoResProductMaster.productNumber(),
EcoResProductVariantDimValue::getDimensionValuesContainer(ecoResColor.Name,ecoResSize.Name,ecoResStyle.Name));
ecoResDistinctProductVariant.SearchName = merchant.Styling; //ecoResProductMaster.SearchName + ecoResColor.Name;
ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
ecoResDistinctProductVariant.ProductMaster = ecoResProductMaster.RecId;
ecoResDistinctProductVariant.insert();
// Product Variant Color
ecoResProductVariantColor.clear();
ecoResProductVariantColor.initValue();
ecoResProductVariantColor.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantColor.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventColorId));
ecoResProductVariantColor.Color = ecoResColor.RecId;
ecoResProductVariantColor.insert();
// Product Variant Style
ecoResProductVariantStyle.clear();
ecoResProductVariantStyle.initValue();
ecoResProductVariantStyle.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantStyle.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventStyleId));
ecoResProductVariantStyle.Style = ecoResStyle.RecId;
ecoResProductVariantStyle.insert();
// Product Variant Size
ecoResProductVariantSize.clear();
ecoResProductVariantSize.initValue();
ecoResProductVariantSize.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantSize.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventSizeId));
ecoResProductVariantSize.Size = ecoResSize.RecId;
ecoResProductVariantSize.insert();
//Product variant translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId,merchant.Product,merchant.Brand);
//Released product
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProductMaster);
inventTable.ItemId = ecoResProductMaster.DisplayProductNumber;
inventTable.NameAlias = merchant.Styling;
inventTable.ABSProduct = merchant.Product;
inventTable.Brand = merchant.Brand; //customized field
inventTable.Fiber = merchant.Fiber;
inventTable.Finish = merchant.Finish;
inventTable.ABSStyle = merchant.Style;
inventTable.Usage = merchant.Usage;
inventTable.Styling = merchant.Styling;
if (inventTable.validateWrite())
{
inventTable.insert();
//Inventory model group
inventModelGroupItem.clear();
inventModelGroupItem.initValue();
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventModelGroupItem.ItemId = inventTable.ItemId;
inventModelGroupItem.ModelGroupId = merchant.InventModelGroupId;
inventModelGroupItem.ModelGroupDataAreaId = curext();
inventModelGroupItem.insert();
//Item group
inventItemGroupItem.clear();
inventItemGroupItem.initValue();
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventItemGroupItem.ItemId = inventTable.ItemId;
inventItemGroupItem.ItemGroupId = merchant.ItemGroupId;
inventItemGroupItem.ItemGroupDataAreaId = curext();
inventItemGroupItem.insert();
//Extended product details - Inventory
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.UnitId = merchant.InventUnitId;
inventTableModule.insert();
//Extended product details - Purchase
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.UnitId = merchant.PurchUnit;
inventTableModule.insert();
//Extended product details - Sales
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.UnitId = merchant.SalesUnit;
inventTableModule.insert();
//Warehouse items
InventItemLocation::createDefault(inventTable.ItemId);
//Supply type setup
inventItemSetupSupplyType.clear();
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
//Product storage dimension group
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{
ecoResStorageDimensionGroupItem.clear();
ecoResStorageDimensionGroupItem.initValue();
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}
//Product tracking dimension group
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResTrackingDimensionGroupProduct.RecId)
{
ecoResTrackingDimensionGroupItem.clear();
ecoResTrackingDimensionGroupItem.initValue();
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
}
inventDim.clear();
inventDim.InventColorId = ecoResColor.Name;
inventDim.InventSizeId = ecoResSize.Name;
inventDim.InventStyleId = ecoResStyle.Name;
inventDim = InventDim::findOrCreate(inventDim);
//Released product variant
inventDimCombination.clear();
inventDimCombination.initValue();
inventDimCombination.DistinctProductVariant = ecoResDistinctProductVariant.RecId;
inventDimCombination.ItemId = inventTable.ItemId;
inventDimCombination.InventDimId = inventDim.InventDimId;
inventDimCombination.insert();
merchant = MerchandisingTable_ds.getNext();
}
}
}
catch
{
error("Error!");
return;
}
info("Done!");
}
{
EcoResProductMaster ecoResProductMaster;
EcoResProductIdentifier ecoResProductIdentifier;
EcoResProductDimensionGroupProduct ecoResProductDimensionGroupProduct;
EcoResProductMasterModelingPolicy ecoResProductMasterModelingPolicy;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResConfiguration ecoResConfiguration;
EcoResProductMasterConfiguration ecoResProductMasterConfiguration;
EcoResColor ecoResColor;
EcoResProductMasterColor ecoResProductMasterColor;
EcoResSize ecoResSize;
EcoResProductMasterSize ecoResProductMasterSize;
EcoResStyle ecoResStyle;
EcoResProductMasterStyle ecoResProductMasterStyle;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
EcoResProductVariantColor ecoResProductVariantColor;
EcoResProductVariantSize ecoResProductVariantSize;
EcoResProductVariantStyle ecoResProductVariantStyle;
InventTable inventTable;
InventTableModule inventTableModule;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventDim inventDim;
InventDimCombination inventDimCombination;
NumberSequenceTable numberSequenceTable;
EcoResProductDisplayProductNumber displayProductNumber;
MerchandisingTable merchant;
merchant = MerchandisingTable_ds.getFirst(1);
try
{
while(merchant.RecId != 0)
{
//ProductMaster
ecoResProductMaster.clear();
ecoResProductMaster.initValue();
numberSequenceTable = EcoResProductParameters::numRefProductNumber().numberSequenceTable();
displayProductNumber = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
ecoResProductMaster.ProductType = EcoResProductType::Item;
ecoResProductMaster.DisplayProductNumber = displayProductNumber;
ecoResProductMaster.SearchName = merchant.Styling;
ecoResProductMaster.Brand = merchant.Brand;
ecoResProductMaster.Styling = merchant.Styling;
ecoResProductMaster.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::PredefinedVariants;
if (ecoResProductMaster.validateWrite())
{
ecoResProductMaster.insert();
ecoResProductIdentifier.clear();
ecoResProductIdentifier.initValue();
ecoResProductIdentifier.ProductNumber = ecoResProductMaster.DisplayProductNumber;
ecoResProductIdentifier.Product = ecoResProductMaster.RecId;
ecoResProductIdentifier.insert();
//Product dimension group
ecoResProductDimensionGroupProduct.clear();
ecoResProductDimensionGroupProduct.initValue();
ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(merchant.EcoResProductDimensionGroupName).RecId;
if (ecoResProductDimensionGroupProduct.validateWrite())
{
ecoResProductDimensionGroupProduct.insert();
}
//Storage dimension group
ecoResStorageDimensionGroupProduct.clear();
ecoResStorageDimensionGroupProduct.initValue();
ecoResStorageDimensionGroupProduct.Product = ecoResProductMaster.RecId;
ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(merchant.StorageDimensionGrpName).RecId;
if (ecoResStorageDimensionGroupProduct.validateWrite())
{
ecoResStorageDimensionGroupProduct.insert();
}
//Tracking dimension group
ecoResTrackingDimensionGroupProduct.clear();
ecoResTrackingDimensionGroupProduct.initValue();
ecoResTrackingDimensionGroupProduct.Product = ecoResProductMaster.RecId;
ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(merchant.EcoResTrackingDimensionGrpName).RecId;
if (ecoResTrackingDimensionGroupProduct.validateWrite())
{
ecoResTrackingDimensionGroupProduct.insert();
}
//Product modeling policy
ecoResProductMasterModelingPolicy.clear();
ecoResProductMasterModelingPolicy.initValue();
ecoResProductMasterModelingPolicy.ProductMaster = ecoResProductMaster.RecId;
if (ecoResProductMasterModelingPolicy.validateWrite())
{
ecoResProductMasterModelingPolicy.insert();
}
//Product translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductMaster.Product, ecoResProductMaster.Brand);
//Color
ecoResColor = EcoResColor::findByName(merchant.Color);
if (!ecoResColor)
{
ecoResColor.clear();
ecoResColor.initValue();
ecoResColor.Name = merchant.Color;
ecoResColor.insert();
}
//Color assigned to product master
ecoResProductMasterColor.clear();
ecoResProductMasterColor.initValue();
ecoResProductMasterColor.Color = ecoResColor.RecId;
ecoResProductMasterColor.ColorProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventColorId));
ecoResProductMasterColor.ColorProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterColor.insert();
//Style
ecoResStyle = EcoResStyle::findByName(merchant.StyleName);
if (!ecoResStyle)
{
ecoResStyle.clear();
ecoResStyle.initValue();
ecoResStyle.Name = merchant.StyleName;
ecoResStyle.insert();
}
//Style assigned to product master
ecoResProductMasterStyle.clear();
ecoResProductMasterStyle.initValue();
ecoResProductMasterStyle.Style = ecoResStyle.RecId;
ecoResProductMasterStyle.StyleProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventStyleId));
ecoResProductMasterStyle.StyleProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterStyle.insert();
//Size
ecoResSize = EcoResSize::findByName(merchant.Size);
if (!ecoResSize)
{
ecoResSize.clear();
ecoResSize.initValue();
ecoResSize.Name = merchant.Size;
ecoResSize.insert();
}
//Size assigned to product master
ecoResProductMasterSize.clear();
ecoResProductMasterSize.initValue();
ecoResProductMasterSize.Size = ecoResSize.RecId;
ecoResProductMasterSize.SizeProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventSizeId));
ecoResProductMasterSize.SizeProductMaster = ecoResProductMaster.RecId;
ecoResProductMasterSize.insert();
//Product variant
ecoResDistinctProductVariant.clear();
ecoResDistinctProductVariant.initValue();
ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
ecoResProductMaster.productNumber(),
EcoResProductVariantDimValue::getDimensionValuesContainer(ecoResColor.Name,ecoResSize.Name,ecoResStyle.Name));
ecoResDistinctProductVariant.SearchName = merchant.Styling; //ecoResProductMaster.SearchName + ecoResColor.Name;
ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
ecoResDistinctProductVariant.ProductMaster = ecoResProductMaster.RecId;
ecoResDistinctProductVariant.insert();
// Product Variant Color
ecoResProductVariantColor.clear();
ecoResProductVariantColor.initValue();
ecoResProductVariantColor.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantColor.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventColorId));
ecoResProductVariantColor.Color = ecoResColor.RecId;
ecoResProductVariantColor.insert();
// Product Variant Style
ecoResProductVariantStyle.clear();
ecoResProductVariantStyle.initValue();
ecoResProductVariantStyle.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantStyle.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventStyleId));
ecoResProductVariantStyle.Style = ecoResStyle.RecId;
ecoResProductVariantStyle.insert();
// Product Variant Size
ecoResProductVariantSize.clear();
ecoResProductVariantSize.initValue();
ecoResProductVariantSize.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantSize.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventSizeId));
ecoResProductVariantSize.Size = ecoResSize.RecId;
ecoResProductVariantSize.insert();
//Product variant translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId,merchant.Product,merchant.Brand);
//Released product
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProductMaster);
inventTable.ItemId = ecoResProductMaster.DisplayProductNumber;
inventTable.NameAlias = merchant.Styling;
inventTable.ABSProduct = merchant.Product;
inventTable.Brand = merchant.Brand; //customized field
inventTable.Fiber = merchant.Fiber;
inventTable.Finish = merchant.Finish;
inventTable.ABSStyle = merchant.Style;
inventTable.Usage = merchant.Usage;
inventTable.Styling = merchant.Styling;
if (inventTable.validateWrite())
{
inventTable.insert();
//Inventory model group
inventModelGroupItem.clear();
inventModelGroupItem.initValue();
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventModelGroupItem.ItemId = inventTable.ItemId;
inventModelGroupItem.ModelGroupId = merchant.InventModelGroupId;
inventModelGroupItem.ModelGroupDataAreaId = curext();
inventModelGroupItem.insert();
//Item group
inventItemGroupItem.clear();
inventItemGroupItem.initValue();
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventItemGroupItem.ItemId = inventTable.ItemId;
inventItemGroupItem.ItemGroupId = merchant.ItemGroupId;
inventItemGroupItem.ItemGroupDataAreaId = curext();
inventItemGroupItem.insert();
//Extended product details - Inventory
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.UnitId = merchant.InventUnitId;
inventTableModule.insert();
//Extended product details - Purchase
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.UnitId = merchant.PurchUnit;
inventTableModule.insert();
//Extended product details - Sales
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.UnitId = merchant.SalesUnit;
inventTableModule.insert();
//Warehouse items
InventItemLocation::createDefault(inventTable.ItemId);
//Supply type setup
inventItemSetupSupplyType.clear();
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
//Product storage dimension group
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{
ecoResStorageDimensionGroupItem.clear();
ecoResStorageDimensionGroupItem.initValue();
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}
//Product tracking dimension group
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResTrackingDimensionGroupProduct.RecId)
{
ecoResTrackingDimensionGroupItem.clear();
ecoResTrackingDimensionGroupItem.initValue();
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
}
inventDim.clear();
inventDim.InventColorId = ecoResColor.Name;
inventDim.InventSizeId = ecoResSize.Name;
inventDim.InventStyleId = ecoResStyle.Name;
inventDim = InventDim::findOrCreate(inventDim);
//Released product variant
inventDimCombination.clear();
inventDimCombination.initValue();
inventDimCombination.DistinctProductVariant = ecoResDistinctProductVariant.RecId;
inventDimCombination.ItemId = inventTable.ItemId;
inventDimCombination.InventDimId = inventDim.InventDimId;
inventDimCombination.insert();
merchant = MerchandisingTable_ds.getNext();
}
}
}
catch
{
error("Error!");
return;
}
info("Done!");
}
No comments:
Post a Comment