Bugfix - Magento 1: Warning: Invalid argument supplied for foreach() in app/code/core/Mage/Rule/Model/Condition/Abstract.php on line 246 Print

  • 11

This error is thrown when editing coupons (where SKU as one of the conditions) in Promotions > Shopping Cart Price Rules. It is a bug in Magento 1.5.1.0 and is fixed in Magento 1.6.2.0.

Warning: Invalid argument supplied for foreach()  in app/code/core/Mage/Rule/Model/Condition/Abstract.php on line 246

To fix this bug, do the following:

1. Create a local override for the file by copying to app/code/local/Mage/Rule/Model/Condition/Abstract.php on line 246 (since we NEVER mod the core!)

2. Comment out the entire getValueSelectOptions() function at line 246 and replace with the following:

public function getValueSelectOptions()
{
$valueOption = $opt = array();
if ($this->hasValueOption()) {
$valueOption = (array) $this->getValueOption();
}
foreach ($valueOption as $k => $v) {
$opt[] = array('value' => $k, 'label' => $v);
}
return $opt;   }

If you are a Create Hosting customer on the Magento Hosting Plan, drop us a support email and we can take care of this for you.


Was this answer helpful?

« Back