Create Product Variant

static void CreateProductVariant(Args _args)
{
    ecoResDistinctProductVariant        ecoResDistinctProductVariant;
    EcoResProductVariantDimensionValue  EcoResProductVariantDimensionValue;
    RefRecId                                   ecoResDistinctProductVariantRecId;
    EcoResProductReleaseManagerBase     releaseManager;
    container productDimensions;
    InventTable inventTable=InventTable::find("item");


    //Create a container to hold dimension values
    productDimensions = EcoResProductVariantDimValue::getDimensionValuesContainer("ConfigurationName",
                                                                                        "Size",
                                                                                        "ColorId",
                                                                                        "InventStyleId");
    //Create Product search name

    ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
                                                                    EcoResProduct::find(InventTable.Product).productNumber(),
                                                                    productDimensions);

    //Create Product variant with Product and dimensions provided

    ecoResDistinctProductVariantRecId = EcoResProductVariantManager::createProductVariant(InventTable.Product,ecoResDistinctProductVariant.DisplayProductNumber,productDimensions);

    //Find newly created Product Variant
    ecoResDistinctProductVariant = ecoResDistinctProductVariant::find(ecoResDistinctProductVariantRecId);
    //Now release the Product variant
    releaseManager = EcoResProductReleaseManagerBase::newFromProduct(ecoResDistinctProductVariant);
    releaseManager.release();
}

 

posted @ 2016-10-19 11:31  止在入门  阅读(384)  评论(0编辑  收藏  举报