opentype Posted December 29, 2022 Posted December 29, 2022 I am using this code in several feed block templates to show a random entry from a selection of entries: {{shuffle($records);}} {{$records = array_slice($records, 0, 1);}} But it doesn’t work for Commerce feed blocks, as $packages is not an array. Anyone knows how to adopt the above code to work with these ActiveRecordIterators?
Solution Daniel F Posted December 29, 2022 Solution Posted December 29, 2022 You could use https://www.php.net/manual/en/function.iterator-to-array.php to get an array from the iterator
Recommended Posts