What is invalid in the foreach in my custom phtml template?

$filters = $helper->getMyFilter();

<?php foreach ($filters as $key => $filter): ?>

I am getting

Invalid arguments supplied for foreach()


$filters may not be an array, that is why it isn't working.

Try to use

if (is_array($filters) || is_object($filters))
    foreach ($filters as $key => $filter)


foreach ((array) $items as $item) {
 // ...
  • Will update, haven't checked that part for a while @Krishna – Sushivam Sep 17 '16 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.