
Originally Posted by
mesnitu
Hi
I'm working on bookx EP import, but I'm getting a lot of this warnings in the log:
PHP Warning: Invalid argument supplied for foreach() in /home/daniel/public_html/zen154.dev/zenadmin/includes/modules/product_bookx/collect_info.php on line 782
As I have SEO uri, possibly the line is different , but I didn't mess with this lines:
It's just a warning, I don't see no working issues, but I wonder what could it be ?
No one else getting this warning ?
PHP Code:
foreach ($product_assigned_authors as $product_assigned_author) {
echo '<div class="drop_down_div">';
echo zen_draw_hidden_field('assigned_author_db_id[' . $author_counter . ']', $product_assigned_author['primary_id']);
echo TEXT_PRODUCTS_BOOKX_AUTHOR . '##' . zen_draw_pull_down_menu('bookx_author_id[' . $author_counter . ']', $authors_array, $product_assigned_author['bookx_author_id']);
if (1 < count($author_types_array)) {
echo TEXT_PRODUCTS_BOOKX_AUTHOR_TYPE . '##' . zen_draw_pull_down_menu('bookx_author_type_id[' . $author_counter . ']', $author_types_array, $product_assigned_author['bookx_author_type_id']);
};
echo '</div>';
$author_counter++;
}
Thanks
Not sure what the issue could be. In the unmodified collect_info.php an empty array is created on line 100:
Code:
$product_assigned_authors = array();
then possibly it is filled with some content on lines 139 and 169:
Code:
$product_assigned_authors[] = array('primary_id' => $assigned_authors->fields['primary_id'], 'bookx_author_id' => $assigned_authors->fields['bookx_author_id'], 'bookx_author_type_id' => $assigned_authors->fields['bookx_author_type_id']);
$product_assigned_authors[] = array('primary_id' => '', 'bookx_author_id' => $author_id, 'bookx_author_type_id' => $bookx_author_type_id);
So far it has always been safe to pass an empty array to a foreach loop, so not sure what the Warning is relating to.
Code:
foreach ($product_assigned_authors as $product_assigned_author) {
Have you made any changes like IF blocks, that prevent line 100 from creating the empty array?
Regards,
p.
Bookmarks