November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Binary data MUST be stored in the assets area as the content in here goes to wherever you've configured your data sotre (local file storage or in Azure a Blob provider).
The correct way is to upload binary data such as images in to the asset area then link to it with a ContentReference on the Variant.
But I'm not storing any binary data, only a image url as a string, and a image type as a string? The images themselves are not handled by epi at all, we have an external service that manages the images, and provides the CDN path to EPI.
You probably want to do this
wcVariant.PackshotMain.Type = ...;
wcVariant.PackshotMain.Path = ...;
The approach is fine, I am just not sure if you need to use BlockData for this. Simple, flat properties might be better and easier
Apologies I was skim reading as I was going in to a meeting. I agree with Quan there can be issues with using Blocks as properties when you're changing structure of model so I try to avoid.
I would also try to use https://world.optimizely.com/documentation/developer-guides/CMS/Content/Properties/generic-propertylist/ instead of a list of blocks if you're not using the blocks for rendering, it makes the editing a lot easier and blocks are designed to be rendered components (when not using as a property which as said I personally avoid).
Thanks for your answers.
I fully agree that using blocks as properties, is not the ideal way to go.
public class ProductImageModel
{
public virtual string Type { get; set; }
public virtual string Path { get; set; }
}
But when i try to assign the above model to the variant, i get: "System.NotSupportedException: The type *********.ProductImageModel can not be mapped to a MetaDataType".
Any ideas on how to solve that?
I have a thought that adding a backingtype of some sort might do the trick, but I have'nt figured out a configuration that works yet.
THe content system does not understand ProductImageModel and how it should be handled. You will need to define a PropertyData that can handle that, then using something like
[BackingType(typeof(PropertyProductImage))]
public virtual PropertyProductImage Image{ get; set; }
(This might belong in the Commerce forum, was unsure where to put it.) I'm fairly new to episerver, so sorry if I'm asking stupid questions.
We are moving our ProductImages out of Epi, and handeling them in a external service, that will provide epi with only a (string)path and a (string)type. I'm making a scheduled job to iterate over our products, and for each product iterate over our variants to find all the images for that variant and store them on the variant.
But I'm unsure about how to best store this data on the variant. Each variant needs to store a property for the main packshot, a property for the main modelshot, and a collection of the remaining images.
One could say that i should store them in the folderstructure as extentions of the ImageData or MediaData classes. But we do not need nor wan't to have this in the allready bloated folderstructure, as it would never be managed in the editor, everything would be managed programaticly. So I'm hoping that the answer is not that this is how you should do this.
The solution i have been trying to implement, storing the data in a class that extends the block class:
These are added to the BaseVariant class like this:
And in the scheduled job i do the following:
Inspecting wcVariant in debug, i can see the blocks with data on it. But if i load the variant from the contentRefrence after the save, there is a block on variant, but the fields of the block are both null.
Am i doing something oviously wrong in my attempt above, or can it be fixed with a slight adjustment?
Or is there a better aproch to this, that i should implement instead?
Thanks in advance for any answers.