London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Category AssetLink Id is always 0

Vote:
0

I create an asset for a specific category (CMS -> Commerce -> Catalog -> select a category -> select All Properties -> Assets -> Add Media), indicate the name of the group. Then Publish changes.

But when I try to get assets for a category, I see that AssetLink ID is 0. My code:

public string GetNodeAssetUrl(NodeContent node, string groupName, bool relative)
{
    string url = string.Empty;
    if (node?.CommerceMediaCollection == null || !node.CommerceMediaCollection.Any())
    {
        return null;
    }

    var foundAsset = node.CommerceMediaCollection.FirstOrDefault(
        item => item.GroupName.ToLower().Contains(groupName.ToLower()));
    if (foundAsset == null)
    {
        return null;
    }

    if (!_contentLoader.Service.TryGet(foundAsset.AssetLink, out IContent content))
    {
        return null;
    }
...

I always see that the content is null and foundAsset.AssetLink.ID == 0. Can someone tell me why is that so? I'm using version 12 of Epi.

#202117
Edited, Mar 14, 2019 14:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.