Home » Magento9 December 2009

Magento: Product Edit Warning: Invalid argument supplied for foreach()


While editing product programatically from frontend. I was trying to change the status of the product with the following code. I was trying to disable the product. Status value 2 = Disabled.


Product could not be edited programatically from frontend. The following error message is shown:

Warning: Invalid argument supplied for foreach()  in /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 937


It seems that product updates are only made on the admin side and you have to change the store view while editing product from frontend.

Write the following before you edit product:

Hence, my new code will be :



Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Thanks! This was quite helpful.

  • Paolo

    u may need to check the number in setAttributeSetId(?)

  • Alex Kochetyga

    Thanks for this solution. Do you know how this can affect on other code related to product that is ran after switching to the admin store?

  • Pleth

    Thank you !!

  • Thank you for this helpful post!

    I was wondering why

    – inserting products from frontend: no problem.
    – updating products from frontend: problem.

  • jpk

    thanks for this…
    it worked like a charm :)

  • Snowcore

    Cheers! Thanks for the tip!

  • Parth Thakkar

    Thanks for your help !!! It worked !!!!