Create a gist now

Instantly share code, notes, and snippets.

@fraga /gist:4490746
Last active Dec 10, 2015

What would you like to do?
Creating Product Master with configuration and it's variant, then releasing it
static void CreateProduct(Args _args)
{
EcoResProductMasterManager manager = EcoResProductMasterManager::construct();
recId productMasterRecId;
EcoResDistinctProductVariant productVariant;
EcoResProductVariantCreationMgr productVariantCreationMgr = new EcoResProductVariantCreationMgr();
container productVariantContainer;
EcoResProductVariantDimValue productVariantDimValue;
EcoResTmpProductVariantSuggestion productVariantSuggestion;
EcoResProductDimGroupSetup productDimGroupSetup = EcoResProductDimGroupSetup::construct();
EcoResProductMasterConfiguration productMasterConfiguration;
EcoResConfiguration productConfiguration;
EcoResProductReleaseSessionManager releaseSessionManager = EcoResProductReleaseSessionManager::newReleaseSession();
try
{
ttsBegin;
//Creates product master
productMasterRecId = manager.createProductMaster("Product Name",
"Product Search Name",
EcoResProductType::Item,
EcoResVariantConfigurationTechnologyType::PredefinedVariants,
5637144576, //EcoResProductDimensionGroup::findByDimensionGroupName("CONFIG").RecId, //Product Group
5637144576, //EcoResStorageDimensionGroup::findByDimensionGroupName("STODIM01").RecId, //Product Tracking Dimension
5637144826); //EcoResTrackingDimensionGroup::findByDimensionGroupName("TRKDIM02").RecId); //Product Tracking Dimension
//Creates product master translations
EcoResProductTranslation::createOrUpdateTranslation(productMasterRecId, "Product Name", "Product Name Desc", "en-us");
productMasterConfiguration.ConfigProductMaster = productMasterRecId;
productMasterConfiguration.Configuration = 5637144593; //productConfiguration = EcoResConfiguration::findByName("STD");
productmasterconfiguration.Description = "Product Standard configuration";
productMasterConfiguration.AdditionalDescription = "Product Additional Description";
productMasterConfiguration.ConfigProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
productMasterConfiguration.insert();
productVariantContainer = EcoResProductVariantDimValue::getDimensionValuesContainer("STD"); //precreated configuration dimension
EcoResProductVariantManager::createProductVariant(productMasterRecId, "Variant A", productVariantContainer);
releaseSessionManager.addProductMasterWithVariants(productMasterRecId);
releaseSessionManager.addLegalEntityForAllProducts(xDataArea::find(curext()).RecId);
releaseSessionManager.execute();
ttsCommit;
}
catch
{
ttsAbort;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment