I want to be able to import catalog content with all related media(assets).
I decided to check how it is done in Commerce Sample site.
I've found that Install Commerce Sample.ps1 script does following steps:
1. Imports catalogs itself (via CatalogImport.exe tool). Suppose that the tool does exactly the same what can be done using CommerceManager online import/export functionality. The tool consumes zip file that contains catalog data serialized into XML. That's pretty simple.
2. Imports media(assets). Catalog media(assets) are stored at CMS site (as global media). For that Add-EpiServerData cmdlet is used:
$sampleAssetsDataFile = Join-Path $sourceContentFolder "SampleAssets.episerverdata" $globalMediaRoot = Get-EPiContentId -ContentTypeGuidString "E56F85D0-E833-4E02-976A-2D11FE4D598C" -ConnectionString $selectedWebApplication.SiteDbConnectionString Add-EPiServerData -ImportSource $sampleAssetsDataFile -DestinationDirectory $selectedWebApplication.PhysicalPath -VirtualDirectory $selectedWebApplication.ApplicationName -DestinationType "ExplicitPage" -DestinationPage $globalMediaRoot -TransactionTimeout (New-TimeSpan -minute 60)
Note that I can't do the same using CMS->Admin UI (that is not possible to specify GlobalMediaRoot as destination page)
3. Ties assets with catalog content. That is done by AssetImporter tool (shipped with EpiServer installation). AssetImporter tool consumes CSV file that contains association records (Variation Code -> Image ID).
So my questions are:
1. How to prepare Assets.episerverdata file. That will contain global media that is not associated with any "regular" content types (pages/blocks), so it is not possible to export data by CMS->Amdin->Tools->Export data? Is it out of the box tool somewhere?
2. How to prepare CSV relation file? Is it out the box tool or sql script somewhere?
I understand that I can solve both my questions by writing custom tool based on CMS/Commerce API, but actually I have no time to do that right now:)
For your first question, yes, we have an internal tool to do that. I'll ask if we can release that tool to partners :)
For the second question, I created a query for you:
select ce.code, cl.name from dbEPiServerCommerceManager.dbo.CatalogItemAsset cia inner join dbEPiServerCommerceManager.dbo.CatalogEntry ce on ce.CatalogEntryId = cia.catalogentryid inner join dbMyEPiServerSite.dbo.tblContent ct on cia.assetkey = ct.contentguid inner join dbMyEPiServerSite.dbo.tblContentLanguage cl on ct.pkId = cl.fkContentId
Change the database's names to match yours.
Thak you, Quan!
Waiting for your decision about sharing the tool, we would really appreciate that.
You can contact me at Quma at episerver.com to get the tool :)
Sorry for the question. what is "Quma"?
Quma is my alias :), you can send email to either quan.mai or quma
Here are simple steps to migrate assets between servers:
AssetImporter.exe MediaMappings.csv -- D:\Websites\MyWebsite -mappingonly
Get the source code for import/export jobs on Gist: https://gist.github.com/whyleee/fcbff840109fc040682f.