Developer forum

Forum » Development » Override StockLocations loop

Override StockLocations loop

Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi,

We are using a template extender in Live Integration so we can override some tags with product live information. unfortunately we were not able to reset/override the StockLocations loop. What's the best way to override a DW loop in a template extender?

Thanks,
Mario


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Something like this maybe?

template.Loops.FirstOrDefault(l => l.Name == "StockLocations")?.Data.Clear();
            var loop = template.GetLoop("StockLocations");
            for ()
            {
                loop.SetTag("tag1", "val1");
                loop.CommitLoop();
            }
Votes for this answer: 1
 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Nicolai,

I tried a similar approach before (template object does not recognize Loops property):
var stocksLoop = template.GetLoop("StockLocations");
stocksLoop.CurrentLoop.Data.Clear();

Was able to get it to work with:

var stocksLoop = template.GetLoop("StockLocations");
stocksLoop.Reset();
stocksLoop = template.GetLoop("StockLocations");

 

Thanks,
BR, Mario

 

You must be logged in to post in the forum