2

I'm attempting to create a new product via an install script, but running into some issues, more specifically when trying to save the product.

The error I'm getting is: Call to a member function getStoreIds() on a non-object

I've isolated the error to when the product saves (see below)

When saving the product the function _saveAttributeValue is called from Mage_Catalog_Model_Resource_Abstract

Within this function the following line is throwing an error $storeIds = Mage::app()->getStore($storeId)->getWebsite()->getStoreIds(true);

This is because when calling Mage::app()->getStore() from an installer script 0 is returned instead of proper store (see: Install script to get access to root category id)

Is there any way around this where I can the product to save

6

Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);

| improve this answer | |
  • it solves the immediate error but then causes a Invalid category IDs. while saving the product since $store->getRootCategoryId() returns null – pzirkind Jul 29 '14 at 0:29
  • my mistake it seems that another module is causing this error, will look at it soon – pzirkind Jul 29 '14 at 13:45
  • thanks! the other error was being triggered by a 3rd party module extending the backend model for entity_attribute – pzirkind Jul 29 '14 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.