Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Uploading image to Sku View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
slycknick - 2/10/2009 8:33:39 AM
   
Uploading image to Sku
I am trying to integrate the Ecommerce module with our existing back office system. Specifically to push our product catalogue up to Kentico and pull new orders down for processing.

I have written some code to push our products up however I seem to be having some problems uploading the SKU image.

I currently have tried this
Dim s As New IO.StreamReader("C:\Temp\SilMid Assets\ASG1D00003.jpg")
Dim imgString As String = CMS.FileManager.AttachmentManager.SaveFileToDisk(“mySite”, skuGUID.ToString, "ASG1D00003", "jpg", s, True, False)
s.Close()

I was then going to update the SKUImagePath with the imgString value.

My code is outside of the CMS project. I have called CMS.CMSHelper.CMSContext.Init() but I get an error ;

{"[SettingsKeyProvider.WebApplicationPhysicalPath]: Web application physical path is not initialized. You must call CMSContext.Init() before running any of your actions."}

Any ideas? Do I need something in my app.config?
Am I using the best approach?

Many Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 2/10/2009 9:58:37 AM
   
RE:Uploading image to Sku
Hello,

could you please try to init some site properties just after CMSContext.Init?

For example:

CMS.CMSHelper.CMSContext.Init();
CMS.CMSHelper.CMSContext.CurrentSiteName = "xxx";
CMS.SettingsProvider.SettingsKeyProvider.WebApplicationPhysicalPath = @"c:\Inetpub\wwwroot\xxx";
CMS.SettingsProvider.SettingsKeyProvider.ApplicationPath = @"/xxx";


Best regards,
Helena Grulichova

User avatar
Certified Developer v7
Certified  Developer v7
slycknick - 2/10/2009 4:43:21 PM
   
RE:Uploading image to Sku
Thanks for the quick reply. That worked great.
I'm sure I'll have more questions in the coming days.
Nick

User avatar
Member
Member
Scott - 1/24/2010 11:42:23 PM
   
RE:Uploading image to Sku
This was just what I needed. Perhaps you should add it to the "Using API and CMS Controls outside CMS project" topic in the developer docs (I'm using 4.1).

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 1/26/2010 5:10:25 AM
   
RE:Uploading image to Sku
Hello,

thank you for your suggestion. We will consider to add it there.

Best regards,
Helena Grulichova