Hi,
In a schedul Job I am downloading images for xyz location and trying to associate with variants. I am trying to do it in 7.5 style.
var contentRepository = ServiceLocator.Current.GetInstance
var contentLoader = ServiceLocator.Current.GetInstance
var loader = ServiceLocator.Current.GetInstance
var referenceConvertor = ServiceLocator.Current.GetInstance
string variantId = "VariantCode";
var variantLink = referenceConvertor.GetContentLink(variantId);
var variant = (EPiServer.Commerce.Catalog.ContentTypes.VariationContent)contentLoader.Get
var databaseConnectionProvider = ServiceLocator.Current.GetInstance
databaseConnectionProvider.ConnectionString = this.DatabaseConnectionStrings[SiteConstants.IntegrationDatabaseConnectionName].ConnectionString;
var fileID = new ContentReference(621);
var commerceMedia = new EPiServer.Commerce.SpecializedProperties.CommerceMedia()
{
AssetLink = fileID,
AssetType = "site.businessmodel.models.media.imagefile",
GroupName = "test2"
};
variant.CommerceMediaCollection.Add(commerceMedia);
contentRepository.Save(variant, EPiServer.DataAccess.SaveAction.Publish);
I am using following code to upload an Assets for a variant.
In Debugging mode I can see CommerceMediaCollection increases every time but I can't see those in CMS/Edit/Catalog window
http://site.development.local/cm/UI/Commerce/Catalog#context=epi.cms.contentdata:///162__CatalogContent
I tried an iis reset also after attaching MediaItem, but cant see those items.
I tried to uplaod a media Item from interface It sucessfull uploaded that content but List was reverted to the visible items there.
Can you spot what I am doing wrong?
Regards
Khurram