protected function _changeArray(&$Products)
{
foreach($Products as $item)
{
Mage::log('Type: '.$item['attribute']);
switch($item['shipping_attribute'])
{
case '0':
$item['is_cargo'] = 'no';
$item['is_bulky'] = 'no';
$item['is_firework'] = 'no';
Mage::log('assigned '.$item['attribute']);
break;
case '1':
$item['is_cargo'] = 'yes';
$item['is_bulky'] = 'no';
$item['is_firework'] = 'no';
Mage::log('assigned '.$item['attribute']);
break;
case '2':
$item['is_cargo'] = 'no';
$item['is_bulky'] = 'yes';
$item['is_firework'] = 'no';
Mage::log('assigned '.$item['attribute']);
break;
case '3':
$item['is_cargo'] = 'no';
$item['is_bulky'] = 'no';
$item['is_firework'] = 'yes';
Mage::log('assigned '.$item['attribute']);
break;
}
Mage::log('"switch" finished!');
}
}
I am trying to change these elements of the Products array, depending on the value of another element of the array. What seems not to happen is they don't get changed... Everything always stays to 'no' value. I know that the 'attribute' value is different in a correct way and that the function goes through the switch-cases correctly, because of the testings that I am writing in the log.
I am printing the Products array after calling my function, and it is not changed. I thought it will work with passing by reference, but nope... I also tried with passing the array the normal way and returning it from the function - unsuccessful again.
What am I doing wrong or not doing enough ?
Oh, yeah, I also tried having the switch-case in the following way:
case '...':
$Products['is_cargo'] = 'yes';
$Products['is_bulky'] = 'no';
$Products['is_firework'] = 'no';
Mage::log('assigned '.$Products['attribute']);
break;
nope again...
foreach($Products as &$item)