• Resolved scmsteve

    (@scmsteve)


    We are seeing these in our logs:

    Most frequent:

    PHP Warning: Invalid argument supplied for foreach() in /home/simplych/public_html/wp-content/plugins/woo-product-feed-pro/woocommerce-sea.php on line 221

    Occasional:

    PHP Warning: Invalid argument supplied for foreach() in /home/simplych/public_html/wp-content/plugins/woo-product-feed-pro/woocommerce-sea.php on line 1543

    PHP Warning: Invalid argument supplied for foreach() in /home/simplych/public_html/wp-content/plugins/woo-product-feed-pro/woocommerce-sea.php on line 1934

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Steve,

    Thanks for using our plugin and letting us know about the PHP warnings. The issue at hand seems to appear when products have no categories attached to them. Theoretically this should not be possible as WooCommerce automatically puts a product in the “Uncategorized” category when you don’t put a product in any category.

    Anyhow, we have just pushed out a new release that should get rid of these warnings. Could you update the plugin and give it a try?

    Thread Starter scmsteve

    (@scmsteve)

    Awesome! Thanks for clearing those warnings up. I installed the update and haven’t seen any since then. I realize it wasn’t probably affecting anything, just making more noise in the log. I also appreciate your insight on the cause, I’ll be looking into that as well to see how we ended up with that weird situation.

    Thread Starter scmsteve

    (@scmsteve)

    I found this post about locating products without categories:

    https://www.damiencarbery.com/2017/12/list-woocommerce-products-with-no-category/

    I ran it on our site, and nothing was returned. I changed it from looking for 0 categories to 1 and it did return products, so the basic code seems to be working, so maybe we don’t have any products without categories. So what was causing the problem? Obviously that script and your code are looking at different things. ?? But having said that, the warnings to seem to be gone now.

    Hi Steve,

    It was this piece of code, using a standard WordPress function, that was not returning anything for some of your products:

    $all_cats = get_the_terms( $productId, 'product_cat' );

    As we didn’t anticipated on this function returning nothing you saw the PHP warning. Anyhow, we did anticipate on it now so issue solved ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.