I am having a custom module for magento 2.4.2 but with php 7.4 I am having this issue:
Notice: Trying to access array offset on value of type null in /public_html/app/code/mymodule/Helper/Data.php on line 242
when trying to save a product in my admin.
My code in this line is:
if (!is_array($section['fields'])) continue;
And the whole //check is:
$sectionOrder = -1;
foreach($sections as $key => $section) {
$sectionOrder++;
if (!is_array($section['fields'])) continue;
if (isset($section['template_id']) && !in_array((int) $section['template_id'], $templateIds)) {
unset($sections[$key]);
$sectionOrder--;
continue;
}
$sections[$key]['order'] = $sectionOrder;
foreach($section['fields'] as $key2 => $_field) {
if (!is_array($_field)) continue;
$sections[$key]['fields'][$key2]['section_order'] = $sectionOrder;
}
}
With php 7.3 it works but with 7.4 I have problem.
Any help please how I can write this? Thanks in advance!