Run mediamapper manually

We are using the mediamapper in a project and it works as expected when we have a product and then we drag in a new image.

But if the image is all ready uploaded to the media folder, is it possible to map that image to a product that is being created?

Litium version: 6

No, not possible!
For that you will need to create an EventListener that fires each time a new product is created and looks inside the media folders to find matching product ID and bind them together.

1 Like

Is this still the way to go? Seems unnecessary to implement a behavior that is already in place with the media mapper. Is there no event that can be triggered to make the media mapper go through the folder again?

Not that I am aware of for the moment, you need to implement that.

Trying to implement something that triggers the media mapper. But I need to make a search on the files and want to make a search like the one in the BO, but from code. Any directions on what to use for the search? Should I use the DataService.CreateQuery or something else?

Yes you can use that, some hints also here:
https://docs.litium.com/documentation/previous-versions/litium-6/litium-documentation/media/import-media-files

How do I search with contains using the dataservice? Started with this but it requires the name to be equal to the value i’m passing in. But I want it to return all that contains the value i’m passing in.

    using (var query = _dataService.CreateQuery<File>())
    {
        var items = query.Filter(x => x
            .Bool(b => b
                .Should(m => m.Field(SystemFieldDefinitionConstants.NameInvariantCulture, "eq", "123"))
                ));
    }

Try “contains” instead of “eq”.

Nice, thank you.