Regarding Custom SKU Field , Image and other custom fields data import ,

kuntesh thakker asked on April 21, 2015 15:20

I want to import Image as a Guid , SKU Custom field Data and other custom fields . How can i do it .

Recent Answers


Josef Dvorak answered on May 6, 2015 17:44

Hello Kuntesh,

The Kentico Import Toolkit is able to import custom fields, however it is not capable of importing the MetaFile object type that the SKU uses, so that needs to be done via API. Here is a short example showing how to import an image from file, and assign it to a SKU.SKUImagePath property:

private void addProductWithImage(SKUInfo sku, string imagePath)
{
    if (sku == null || String.IsNullOrEmpty(imagePath))
    {
        return;
    }

    if (File.Exists(imagePath))
    {
        // Get file contents from file system
        byte[] imageBinaryData = File.ReadAllBytes(imagePath);

        if (imageBinaryData != null)
        {
            MetaFileInfo file = new MetaFileInfo();
            file.MetaFileObjectID = sku.SKUID;
            file.MetaFileBinary = imageBinaryData;
            file.MetaFileObjectType = "ecommerce.sku";
            file.MetaFileGroupName = "Image";
            file.MetaFileName = "SampleImage.gif";
            file.MetaFileExtension = ".gif";
            file.MetaFileSize = imageBinaryData.Length;
            file.MetaFileMimeType = "image/gif";
            file.MetaFileImageWidth = 100;
            file.MetaFileImageHeight = 100;
            file.MetaFileSiteID = CurrentSite.SiteID;
            file.Insert();

            sku.SKUImagePath = MetaFileInfoProvider.GetMetaFileUrl(file.MetaFileGUID, file.MetaFileName);
            sku.Update();
        }
    }
}
0 votesVote for this answer Mark as a Correct answer

kuntesh thakker answered on May 7, 2015 15:37

Thanks .what about multiple image for a product as i tried for same but it uploaded only one image

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.