I have this code that works:
foreach ($plentymarkets_variation['properties'] as $row) {
if (strpos($row['values']['0']['value'], $needle_de_1) === 0) {
$result_de_1 = $row['values']['0']['value'];
$shopware_product["translations"]["0"]["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
$shopware_product["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
break;
}
Now when i try to make an elseif statement i get an 500 error if the value $row['values']['1']['value'] is false like this:
foreach ($plentymarkets_variation['properties'] as $row) {
if (strpos($row['values']['0']['value'], $needle_de_1) === 0) {
$result_de_1 = $row['values']['0']['value'];
$shopware_product["translations"]["0"]["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
$shopware_product["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
break;
}
elseif (strpos($row['values']['1']['value'], $needle_de_1) === 0) {
$result_de_1 = $row['values']['1']['value'];
$shopware_product["translations"]["0"]["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
$shopware_product["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
break;
}
elseif (strpos($row['values']['2']['value'], $needle_de_1) === 0) {
$result_de_1 = $row['values']['2']['value'];
$shopware_product["translations"]["0"]["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
$shopware_product["customFields"]["free1"] = str_replace("Text_de_1_","",$result_de_1);
break;
}
elseif (empty($plentymarkets_variation['item']['free1'])) {
$shopware_product["customFields"]["free1"] = " ";
$shopware_product["translations"]["0"]["customFields"]["free1"] = " ";
}
}
Actually there is a value in the first if statement but there should be a false response from first elseif statement. Shouldn't that work?
Actually it already worked but now it seems to not work anymore and i can't explain why. The strukture from the array changed a little bit but i adapt it already as far as i can see.