krilin
December 10, 2019, 12:09pm
1
Hi!
We are supposed to use MediaMapper but I’m not sure how to use it and if it works for us.
Our Customer has a base product with id V-1234.
Variants ids are named after color and size, for example:
123401201
1234 - model
012 - color
01 - size
So the same color has like 2-7 different sizes.
123401201 (blue, XS)
123401202 (blue, S)
123401203 (blue, M)
etc…
The image uploaded is namned 1234012.jpg, meaning all variant of that color 1234012XX should have that image connected.
Can this be solved with MediaMapper?
Thanks!
/Kristoffer
Litium version: 6.3.1
MediaMapper: 4.0.1
Sorry ProductMediaMapper does not support multi variants mapping. It maps one to one. So you need to have distinct images to distinct variatIds.
krilin
December 10, 2019, 1:05pm
3
Ok, thanks for the Quick response.
Is there any way to hook into/extend the MediaMapper to create your own functionallity?
/Kristoffer
Sorry not extendable but you can create a background job to perform the logic you would like to have on existing images.
krilin
December 10, 2019, 2:11pm
5
Thanks!
I’m thinking of hooking into the file create event using this:
I want to subscribe to an event when a file, preferably images only, as been uploaded.
I’ve tried subscribing to Litium.Media.Events.FileCreated but it doesn’t seem to be triggered when I upload an image in backoffice.
Am I missing something?
But the event does not get triggered on file upload. Do I need to add something i web.config maybe or should the code be triggered anyway?
If you did as the example and have the “[Autostart]” attribute you don’t need anything extra in web.config.
krilin
December 10, 2019, 2:28pm
7
Ok, thanks. I have it but it still doesn’t trigger but now I know that is all I need to do.
1 Like
krilin
December 10, 2019, 2:43pm
9
Just tried it with no luck. I guess it should work Litium 6 as well?
NilsN
December 10, 2019, 3:44pm
10
I just tried the same code from the other thread in Litium 6.3.7, and I can hit the break point when the event fires from uploading a new file.
Can you share some code from your implementation?
krilin
December 11, 2019, 7:56am
11
Strange! I just added this class to my project. It is a 6.3.1 but I guess that is not the issue.
[Autostart]
public class FileCreatedEventHandler : IDisposable
{
private readonly Litium.Events.ISubscription<Litium.Media.Events.FileCreated> _subscription;
public FileCreatedEventHandler(EventBroker eventBroker)
{
_subscription = eventBroker.Subscribe<Litium.Media.Events.FileCreated>(fileEvent =>
{
var newGuid = fileEvent.Item.SystemId; // caught this break point
});
}
public void Dispose()
{
_subscription.Dispose();
}
}
I guess that should be enough?
/Kristoffer
It looks correct, doesn’t it still get hit?
krilin
December 11, 2019, 8:52am
13
Hmm, all of a sudden it works. Strange, but I’m happy at the moment.
Thanks for the help!
2 Likes
system
Closed
January 8, 2020, 8:52am
14
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.