Developer forum

Forum » Ecommerce - Standard features » Image template tags empty in razor template

Image template tags empty in razor template

Unnsteinn Garðarsson
Unnsteinn Garðarsson
Reply

Hello, I am debugging an issue on our headless solution which surfaced just recently. The issue is that we are using razor templates to return JSON and consuming them as feeds for all our checkout process since the cart api was not ready when we began. This has worked seamlessly until a week ago or so. The issue is that the template tags for images are all of a sudden empty.

This is the code in the feed template that provides the image path.
 

    string GetImage(LoopItem orderLine)
    {
        var images = new List<string>
        {
                    orderLine.GetString("Ecom:Product.PrimaryImage"),
                    orderLine.GetString("Ecom:Product.Image.Alt_1"),
                    orderLine.GetString("Ecom:Product.Image.Alt_2"),
                    orderLine.GetString("Ecom:Product.Image.Alt_3"),
                    orderLine.GetString("Ecom:Product.Image.Alt_4"),
                    orderLine.GetString("Ecom:Product.Image.Alt_5"),
                    orderLine.GetString("Ecom:Product.Image.Alt_6"),
                    orderLine.GetString("Ecom:Product.Image.Alt_7"),
                    orderLine.GetString("Ecom:Product.ImageAlt_1.Clean"),
                };

        foreach (var item in images)
        {
            if (item.Length > 0)
            {
                return item;
            }
        }

        return "";
    }

And this function is being called like this.

        List<OrderLine> orderLines = new List<OrderLine>();
        foreach (LoopItem ol in GetLoop("OrderLines"))
        {
            orderLine.Product.ImagePath = GetImage(ol);

        }

 

- The solution is currently running DW 9.13.2
- The last update was in early february so that is not a cause.
- The issue is only happening on our live environment (works on development and staging)
- I have tried to add all other template tags for imags that I can find in the documentation inside the images list in the GetImage function, every single one is empty.
- The solution is using the new image patterns

- The shop is using the following image patterns

- Below is an example of how the images are named in the Files/Images/Vörumyndir folder

- I even tried to use the dwapi/ecommerce/cart endpoint to create a cart and then get the cart, in that case I just get the default image.

- I tried to use the ProductImageService.GetImageFromProduct function inside my template feed but that just returns an empty string as well.
- I tried to rename the image folder from Vörumyndir to Vorumyndir but that did not matter.
- I diffed the GlobalSettings for staging and live and saw nothing of interest.

- I probably tried a lot of other stuff that I don't remember, spent a whole day on this without any success.


If anyone has any idea, I would really be thankful.

 

Regards.

Unnsteinn


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Unnsteinn,

Sounds like a known issue: can I please have you try with most recent version 9.13.4. Let me know if this suggestion resolves the problem you have encountered.

BR
Snedker

 
Unnsteinn Garðarsson
Unnsteinn Garðarsson
Reply

The development and staging environments are both running 9.13.2 and it works there.

 

You must be logged in to post in the forum