Friday, July 8, 2016

Update ProductDimension, StorageDimension & SearchName of Items/Products

We had a requirement to update ProductDimension and StorageDimension of all the items. I wrote 2 jobs for the same. Below are those:

Update ProductDimension:
static void UpdateProductDimension(Args _args)
{
    EcoResProduct                       ecoResProduct;
    EcoResProductDimensionGroupProduct  ecoResProductDimensionGroupProduct;
 
    while select ecoResProduct
        where ecoResProduct.RecId != 0
    {
        ecoResProductDimensionGroupProduct.initFromProduct(ecoResProduct);
        ecoResProductDimensionGroupProduct.ProductDimensionGroup = 'NameHere';
        ecoResProductDimensionGroupProduct.insert();
    }
 
    info("Done");
}

Update StorageDimension:
static void Job48(Args _args)
{
    EcoResProduct                       ecoResProduct;
    EcoResStorageDimensionGroup         ecoResStorageDimensionGroup;
    EcoResStorageDimensionGroupProduct  ecoResStorageDimensionGroupProduct;
    EcoResStorageDimensionGroupItem     ecoResStorageDimensionGroupItem;
    InventTable                         inventTable;
 
    select Name from ecoResStorageDimensionGroup
        where ecoResStorageDimensionGroup.Name == 'NameHere';
 
    while select ecoResProduct
        join inventTable
        where ecoResProduct.RecId == inventTable.Product
    {
        ecoResStorageDimensionGroupItem.initValue();
        ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.dataAreaId;
        ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
        ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroup.RecId;
        ecoResStorageDimensionGroupItem.insert();
    }
 
    info("Done");
}

Update SearchName:
static void Job48(Args _args)
{
    EcoResProductTranslation    ecoResProductTranslation;
    InventTable                 inventTable;
    EcoResProduct               ecoResProduct;
 
    update_recordset inventTable
    setting NameAlias = ecoResProductTranslation.Name
    join ecoResProduct
    where ecoResProduct.RecId == inventTable.Product
    join ecoResProductTranslation
    where ecoResProductTranslation.Product == ecoResProduct.RecId
    && ecoResProductTranslation.Name == 'Bentinck One Seater Sofa in Provincial Teak Finish with Mudramark';
 
    info("Done");
}

ReferenceSource: http://fandyax.blogspot.in/2013/04/how-to-using-x-create-item-in.html


No comments:

Post a Comment