I'm trying to add a blocks to a page programatically. The blocks randomize on page refresh.
I've found this is fine with blocks I create muself but doesn't work for self optimizing blocks.
Code I have looks like this:
var contentRepository = ServiceLocator.Current.GetInstance(); var blocks = contentRepository.GetChildren(bannerFolder).Take(bannerQty);
This works fine for blocks I create but not for self optimizing blocks. They all inherit from BlockData so didn't think this would present an issue.
Any way to resolve this?
Have you tried adding LanguageSelector.AutoDetect(true) to you GetChildren() call? I recall that will give an unfiltered list which might include the S.O.B. which I recall work with some kind of Visitor Group internally.