I get this error when I include
$installer->createEntityTables( $this->getTable('red/red') );
I am using enterprise 1.11
I have also seen alternative to that is type every thing which is really time consuming. Could someone please tell me who to make this function work.
[previous:Exception:private] =>
[xdebug_message] => ( ! ) Mage_Eav_Exception: Can't create table: red_faqs_eavexample in C:\wamp\www\ubt.onlocal.com.au\app\Mage.php on line 549
Call Stack
#TimeMemoryFunctionLocation
10.0003690528{main}( )..\index.php:0
20.00271167384Mage::run( )..\index.php:81
30.01012776112Mage_Core_Model_App->run( )..\Mage.php:640
40.02304545784Mage_Core_Model_App->_initModules( )..\App.php:338
50.46364871080Mage_Core_Model_Resource_Setup::applyAllUpdates( )..\App.php:412
60.528411772936Mage_Core_Model_Resource_Setup->applyUpdates( )..\Setup.php:235
70.528611769664Mage_Core_Model_Resource_Setup->_installResourceDb( )..\Setup.php:327
80.528611769824Mage_Core_Model_Resource_Setup->_modifyResourceDb( )..\Setup.php:421
90.529511778144include( 'C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php' )..\Setup.php:624
100.529711778712Mage_Eav_Model_Entity_Setup->createEntityTables( )..\install-0.1.0.php:6
)
Error in file: "C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php" - Can't create table: red_faqs_eavexample
#0 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#2 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#3 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(412): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(338): Mage_Core_Model_App->_initModules()
#6 C:\wamp\www\ubt.onlocal.com.au\app\Mage.php(640): Mage_Core_Model_App->run(Array)
#7 C:\wamp\www\ubt.onlocal.com.au\index.php(81): Mage::run('', 'store')
#8 {main}
This is a problem with an error being triggered when it shouldn't be. Long story short, MySQL doesn't support DDL transactions, and in the course of the method DDL routines are being found in the SQL and an error is thrown.
The easy answer is to comment out this line:
lib/Varien/Db/Adapter/PDO/Mysql.php
protected function _checkDdlTransaction($sql)
{
if (is_string($sql) && $this->getTransactionLevel() > 0) {
$startSql = strtolower(substr(ltrim($sql), 0, 3));
if (in_array($startSql, $this->_ddlRoutines)) {
// comment this out: trigger_error(Varien_Db_Adapter_Interface::ERROR_DDL_MESSAGE, E_USER_ERROR);
}
}
}
Doing so allows your module to install. Obviously hacking a core file is a terrible idea. You should extend the method or allow the SQL to run, and then translate the generated SQL into the Magento MySQL API, as seen in core sql setup scripts. The latter is a major pain.. the better idea would be to extend the method.
More here on background information and troubleshooting.
Related
Hy
After the onepage checkout, in Magento, I received the following email error message
...
Payment transaction failed.
Reason
Mage registry key "_singleton/model/observer" already exists
Checkout Type
onepage
....
And on the admin page, when trying to delete this oreder, same error, again:
There has been an error processing your request
Mage registry key "_singleton/model/observer" already exists
Trace:
#0 /app/Mage.php(223): Mage::throwException('Mage registry k...')
#1 /app/Mage.php(478): Mage::register('_singleton/mode...', false)
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('model/observer')
#3 /app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('cataloginventor...', Array)
#4 /app/code/core/Mage/Core/Model/Abstract.php(466): Mage::dispatchEvent('cataloginventor...', Array)
#5 /app/code/core/Mage/CatalogInventory/Model/Stock/Item.php(787): Mage_Core_Model_Abstract->_afterSave()
#6 /app/code/core/Mage/Core/Model/Abstract.php(319): Mage_CatalogInventory_Model_Stock_Item->_afterSave()
#7 l/app/code/core/Mage/CatalogInventory/Model/Stock.php(210): Mage_Core_Model_Abstract->save()
#8 /app/code/core/Mage/CatalogInventory/Model/Observer.php(809): Mage_CatalogInventory_Model_Stock->backItemQty('542', 1)
#9 /app/code/core/Mage/Core/Model/App.php(1338): Mage_CatalogInventory_Model_Observer->cancelOrderItem(Object(Varien_Event_Observer))
#10 /app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_CatalogInventory_Model_Observer), 'cancelOrderItem', Object(Varien_Event_Observer))
#11 /app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('sales_order_ite...', Array)
..and so on
This only happends to orders that have more than one item.
Any help will be appreciated, especially because the website is in production now.
Many thanks
Let me add a bit of Magento 'anatomy' to Alan's answer:
From your error log:
#10 /app/code/core/Mage/Core/Model/App.php(1317): `Mage_Core_Model_App->_callObserverMethod(Object(Mage_CatalogInventory_Model_Observer), 'cancelOrderItem', Object(Varien_Event_Observer))
class: Mage_CatalogInventory_Model_Observer
model: cataloginventory/observer
method: cancelOrderItem
This mean what #2 should be:
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('cataloginventory/observer')
But you have:
#2 /app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('model/observer')
Why it failed:
1) when Magento try to execute Mage::getSingleton('model/observer') it call getSingleton() function from Alan's answer.
2) registry don't have '_singleton/model/observer' so it try to register it:
self::register($registryKey, self::getModel($modelClass, $arguments));
3) it call self::getModel('model/observer', array())) for registration and this method fails because you don't have such model.
Again, you have 'model/observer' model in one of your xml configuration files, but Magento can't find physical file with this model.
What to do?
This is occurs on 'sales_order_item_cancel' event, so try to find this string in config.xml files in third-party extension folders.
If in one of config.xml you find something like:
...
<events>
...
<sales_order_item_cancel>
<observers>
<inventory>
<class>model/observer</class>
<method>cancelOrderItem</method>
</inventory>
</observers>
</sales_order_item_cancel>
...
</events>
...
Just comment <sales_order_item_cancel> section.
If you want to make it working, set correct value in <class>model/observer</class> section.
That's a curious error -- my guess is you're dealing with a "core-hack"/edut (perhaps unintentionally) of your app/Mage.php file.
If you look at your stack trace, Magento calls
Mage::getSingleton('model/observer')
This is Magento's ways of saying "Instantiate a model/observer object, and make it a singleton instance", If you're not familiar with them, singletons are a "global" object that can only be instantiated once. If you try to instantiate a singleton again you get the original instance.
If you look at the implementation of getSingleton
#File: app/Mage.php
public static function getSingleton($modelClass='', array $arguments=array())
{
$registryKey = '_singleton/'.$modelClass;
if (!self::registry($registryKey)) {
self::register($registryKey, self::getModel($modelClass, $arguments));
}
return self::registry($registryKey);
}
You can see the call to self::registry from your stack trace that causes the error. However, you can also see that Magento checks to make sure the registry key doesn't exist via the if (!self::registry($registryKey)) { conditional.
My guess is someone changed the definition of getSingleton, or registry or register in your app/Mage.php file. In a sock Magento system it should not be possible to receive the exact error you've posted here.
After updating my magento instance from 1.4.0 to 1.7.0.2 I've got the following error:
Invalid backend model specified: customer_entity/address_attribute_backend_region
The error occurs during the checkout process while the customer is selecting the adress from drop-down list and press the "continue" button.
A AJAX-request to /checkout/onepage/saveBilling/ fails, the second request to checkout/onepage/getAdditional responses. The customer will be redirected to the cart overview page, but content the failed ajax response displays an error report number, which can be looked up at with FTP in the folder var/reports/####reportnumber###.log
EDIT: Stack trace
a:5:{i:0;s:81:"Invalid backend model specified: customer_entity/address_attribute_backend_region";i:1;s:1907:"#0 /home/www/p10000/html/magento/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php(346): Mage::exception('Mage_Eav', 'Invalid backend...')
#1 /home/www/p10000/html/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1094): Mage_Eav_Model_Entity_Attribute_Abstract->getBackend()
#2 /home/www/p10000/html/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(998): Mage_Eav_Model_Entity_Abstract->_setAttributeValue(Object(Mage_Customer_Model_Address), Array)
#3 /home/www/p10000/html/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(959): Mage_Eav_Model_Entity_Abstract->_loadModelAttributes(Object(Mage_Customer_Model_Address))
#4 /home/www/p10000/html/magento/app/code/core/Mage/Core/Model/Abstract.php(225): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Customer_Model_Address), '209', NULL)
#5 /home/www/p10000/html/magento/app/code/core/Mage/Checkout/Model/Type/Onepage.php(246): Mage_Core_Model_Abstract->load('209')
#6 /home/www/p10000/html/magento/app/code/core/Mage/Checkout/controllers/OnepageController.php(320): Mage_Checkout_Model_Type_Onepage->saveBilling(Array, '209')
#7 /home/www/p10000/html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveBillingAction()
#8 /home/www/p10000/html/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveBilling')
#9 /home/www/p10000/html/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#10 /home/www/p10000/html/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#11 /home/www/p10000/html/magento/app/Mage.php(686): Mage_Core_Model_App->run(Array)
#12 /home/www/p10000/html/magento/index.php(101): Mage::run('', 'store')
#13 {main}";s:3:"url";s:60:"/magento/index.php/checkout/onepage/saveBilling/";s:11:"script_name";s:18:"/magento/index.php";s:4:"skin";s:11:"german";}
I found this topic: http://www.magentocommerce.com/boards/viewthread/261499/#t350593
So I created this statement (the first two lines I found at learningmagento.com, but they are incomplete and leads into a total break of the onepage/saveBilling-Page, if you don't change the source model, too.
UPDATE `eav_attribute` SET `backend_model` = 'customer/entity_address_attribute_backend_street' WHERE `attribute_code` ='street' LIMIT 1 ;
UPDATE `eav_attribute` SET `backend_model` = 'customer/entity_address_attribute_backend_region' WHERE `attribute_code` ='region' LIMIT 1 ;
UPDATE `eav_attribute` SET `source_model` = 'customer/entity_address_attribute_source_country' WHERE `source_model` = 'customer_entity/address_attribute_source_country' LIMIT 1 ;
UPDATE `eav_attribute` SET `source_model` = 'customer/entity_address_attribute_source_region' WHERE `source_model` ='customer_entity/address_attribute_source_region' LIMIT 1 ;
It worked for me. The AJAX request responses with a validation error for the phone number in my case, but this can be solved easily.
The "customer_entity/..." can be also found in the table "eav_entity_type", but in my case it was (not yet) necessary to change the value.
i have moved a Magento installation from a preview system to my local machine for developing and testing.
i have setup the BASE URL to my V-Host in the database.
The frontend works but i cant get into the admin panel.
if i log in, i got the following error message:
No region found within the locale 'de'
Trace:
#0 /var/www/myProjectName/lib/Zend/Currency.php(101): Zend_Currency->setLocale(NULL)
#1 /var/www/myProjectName/app/code/core/Mage/Core/Model/Locale.php(575): Zend_Currency->__construct('USD', NULL)
#2 /var/www/myProjectName/app/code/core/Mage/Directory/Model/Currency.php(233): Mage_Core_Model_Locale->currency('EUR')
#3 /var/www/myProjectName/app/code/core/Mage/Directory/Model/Currency.php(216): Mage_Directory_Model_Currency->formatTxt(NULL, Array)
#4 /var/www/myProjectName/app/code/core/Mage/Directory/Model/Currency.php(197): Mage_Directory_Model_Currency->formatPrecision(NULL, 2, Array, true, false)
#5 /var/www/myProjectName/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php(82): Mage_Directory_Model_Currency->format(NULL)
#6 /var/www/myProjectName/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php(62): Mage_Adminhtml_Block_Dashboard_Bar->format(NULL)
#7 /var/www/myProjectName/app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php(74): Mage_Adminhtml_Block_Dashboard_Bar->addTotal('Revenue', NULL)
#8 /var/www/myProjectName/app/code/core/Mage/Core/Block/Abstract.php(238): Mage_Adminhtml_Block_Dashboard_Totals->_prepareLayout()
#9 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#10 /var/www/myProjectName/app/code/core/Mage/Adminhtml/Block/Dashboard.php(50): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...')
#11 /var/www/myProjectName/app/code/core/Mage/Core/Block/Abstract.php(238): Mage_Adminhtml_Block_Dashboard->_prepareLayout()
#12 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#13 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...', 'dashboard')
#14 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/dashb...', 'dashboard')
#15 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#16 /var/www/myProjectName/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#17 /var/www/myProjectName/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#18 /var/www/myProjectName/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#19 /var/www/myProjectName/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#20 /var/www/myProjectName/app/code/core/Mage/Adminhtml/controllers/DashboardController.php(40): Mage_Adminhtml_Controller_Action->loadLayout()
#21 /var/www/myProjectName/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Adminhtml_DashboardController->indexAction()
#22 /var/www/myProjectName/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#23 /var/www/myProjectName/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#24 /var/www/myProjectName/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#25 /var/www/myProjectName/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#26 /var/www/myProjectName/index.php(87): Mage::run('', 'store')
#27 {main}
Can i set the region anywhere? everything i found with google cant help me out.
Just tell me what else you want to know.
I hope you can help me!
Thanks smo
So basically:
got to core_config_data in your database
and delete the line where path = general
I got the same problem but there was no "general" Config-Entry without any other path and content, so i need to debug the problem a bit deeper.
Btw - you can search the config-entry like this:
SELECT * FROM core_config_data WHERE core_config_data.path = 'general';
To me, it seems to be a Firefox-only Problem and i think, its out of the language-setting from the browser. Its inside the Zend-currency-handling. Only Firefox has the problem - Chrome, Edge, Internet Explorer works well!
So i fixed the Magento-Code like that a bit dirty but it works:
Copy lib/Zend/Currency.php to app/code/local/Zend/Currency.php and edit this.
Now you can overwrite the Zend-Framework file.
Go to the following line at copied:
public function setLocale($locale = null)
#require_once 'Zend/Locale.php';
try {
$locale = Zend_Locale::findLocale($locale);
Add last Line:
public function setLocale($locale = null)
{
#require_once 'Zend/Locale.php';
try {
$locale = Zend_Locale::findLocale($locale);
if ( $locale == 'de' ) $locale = 'de_DE'; // zend fix the firefox-locale error
After that, you can edit the products again!
This Variant is also updateable out of the overwrite-code.
Hope that helps!
It happens that the locale is defined based on your browser locale detection. You can like or not this behavior but in this case that's the reason you have this error message.
To fix that you have to change the priority or switch the locale supported by your browser. What I mean by priority is that the browser provide a list of supported language. For example you may have something like that Accept-Language: da, en-gb;q=0.8, en;q=0.7
In your case it searches de but your browser doesn't support it. So you may use "Quick Locale" for firefox to switch to en-US or de-DE for example to prevent such errors if you use this one or something similar. It's not a but in Magento, it's a wanted behavior I think.
when i laoding admin panel i got this error.
How can i solve this?
There has been an error processing your request
Mage registry key "_singleton/awall/feed_extensions" already exists
Trace:
#0 /var/www/magento_upgrade/app/Mage.php(222): Mage::throwException('Mage registry k...')
#1 /var/www/magento_upgrade/app/Mage.php(476): Mage::register('_singleton/awal...', false)
#2 /var/www/magento_upgrade/app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('awall/feed_exte...')
#3 /var/www/magento_upgrade/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#4 /var/www/magento_upgrade/app/code/core/Mage/Core/Controller/Varien/Action.php(528): Mage::dispatchEvent('controller_acti...', Array)
#5 /var/www/magento_upgrade/app/code/core/Mage/Adminhtml/Controller/Action.php(160): Mage_Core_Controller_Varien_Action->preDispatch()
#6 /var/www/magento_upgrade/app/code/core/Mage/Core/Controller/Varien/Action.php(408): Mage_Adminhtml_Controller_Action->preDispatch()
#7 /var/www/magento_upgrade/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#8 /var/www/magento_upgrade/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#9 /var/www/magento_upgrade/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#10 /var/www/magento_upgrade/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#11 /var/www/magento_upgrade/index.php(87): Mage::run('', 'store')
#12 {main}
What Usman said is right but the mystery is how could this happen?
She must be using extension from AW, it has an observer in <controller_action_predispatch>
It will call class awall/feed_extensions, type Singleton
That's why it will create registry with name _singleton/awall/feed_extensions
To debug it, we can use php's debug backtrace.
Put this line in your Mage.php under public static function registry:
public static function registry($key)
{
$str = Varien_Debug::backtrace(true, false);
if(!empty($str)){
Mage::log($str);
}
if (isset(self::$_registry[$key])) {
return self::$_registry[$key];
}
return null;
}
Using this we can backtrace who call the registry (other than the observer) because in normal condition there should not any code that call the registry directly (_singleton/awall/feed_extensions) so it should have never been called more than once.
It will log the result in [MagentosRoot]/var/log/system.log
Make sure you have turn on your log settings, in admin panel:
System > Configuration > Developer > Log Settings > Enabled [Yes]
Because you can't open your admin panel right now, you need to change it directly from database
Use this query to see if you have turn on your log setting or not:
mysql> select * from core_config_data where path like 'dev/log/active';
+-----------+---------+----------+----------------+-------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+----------------+-------+
| 244 | default | 0 | dev/log/active | 1 |
+-----------+---------+----------+----------------+-------+
1 row in set (0.00 sec)
value = 1 means you have turn it on.
If you haven't had that value in your database, just insert it:
insert into core_config_data (scope, scope_id, path, value) values ('default', 0, 'dev/log/active', 1);
If the value in database is 0, change it into 1.
This because you already registered the same key name _singleton/awall/feed_extensions. As you can see in Mage.php
public static function register($key, $value, $graceful = false)
{
if (isset(self::$_registry[$key])) {
if ($graceful) {
return;
}
self::throwException('Mage registry key "'.$key.'" already exists');
}
self::$_registry[$key] = $value;
}
So try to register using other name.
For me, it worked to simply delete all files related to AheadWorks ("AW" on them) and reinstalling, carefully this time, by putting each file on the corresponding folder.
Before refreshing the admin page, find Mage_Compiler.xml and make sure there's a line like <active>false</active>.
Daunting, a bit.
Otherwise, try this:
first go to app/etc/modules/aw_all.xml
change true to false
first go to app/etc/modules/aw_blog.xml
change true to false
then log in to admin you admin will work now.
then
go to system->tools->compilation
disable it.
now
first go to app/etc/modules/aw_all.xml
change false to true
go to app/etc/modules/aw_blog.xml
change false to true
and then check if it is working or not..
I'm late to this question but I had the same problem last night and hope this answer will help someone else (this error cost me a day). I'm using a Magento 1.9 application with a Mage World extension. On my local environment, I switched branches to work on something else but I kept getting the generic Magento error page. Looking at the var/log/system.xml, I saw this:
a:5:{i:0;s:70:"Mage registry key "_singleton/onestepcheckout/observer" already exists";i:1;s:1691:"#0 C:\Sites\myintent-shop\app\Mage.php(223): Mage::throwException('Mage registry k...')
#1 C:\Sites\myintent-shop\app\Mage.php(477): Mage::register('_singleton/ones...', false)
#2 C:\Sites\myintent-shop\app\code\core\Mage\Core\Model\App.php(1316): Mage::getSingleton('onestepcheckout...')
#3 C:\Sites\myintent-shop\app\Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#4 C:\Sites\myintent-shop\app\code\core\Mage\Core\Controller\Varien\Action.php(339): Mage::dispatchEvent('controller_acti...', Array)
#5 C:\Sites\myintent-shop\app\code\core\Mage\Cms\Helper\Page.php(113): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#6 C:\Sites\myintent-shop\app\code\core\Mage\Cms\Helper\Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#7 C:\Sites\myintent-shop\app\code\core\Mage\Cms\controllers\IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#8 C:\Sites\myintent-shop\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Cms_IndexController->indexAction()
#9 C:\Sites\myintent-shop\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#10 C:\Sites\myintent-shop\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 C:\Sites\myintent-shop\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#12 C:\Sites\myintent-shop\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#13 C:\Sites\myintent-shop\index.php(87): Mage::run('', 'store')
#14 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}
Turns out that I had to clear my cache directory. Easiest way to do this was to go to root -> var -> cache and delete all the "mage-*" folders within the "cache" folder (note: I kept the cdn.cache file).
So I'm loading a collection of products using this code:
$magento_time= 'some time string';
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addFieldToFilter(array(
array('attribute'=> 'updated_at', 'gt'=> date('Y-m-d H:i:s', strtotime($magento_time))),
));
$collection->save();
And getting this error in return on save:
Warning: Invalid argument supplied for foreach() in /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 970
#0 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(970): mageCoreErrorHandler(2, 'Invalid argumen...', '/var/www/magent...', 970, Array)
#1 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.php(925): Mage_Eav_Model_Entity_Abstract->_collectSaveData(Object(Mage_Catalog_Model_Product))
#2 /var/www/magento/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Product))
#3 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(845): Mage_Core_Model_Abstract->save()
#4 /var/www/magento/app/code/local/MyModule/controllers/IndexController.php(16): Mage_Eav_Model_Entity_Collection_Abstract->save()
#5 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(376): MyModule_IndexController->sayHelloAction()
#6 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch('sayHello')
#7 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /var/www/magento/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#9 /var/www/magento/index.php(68): Mage::run()
#10 {main}
How do I save products back to the database after they've been loaded into a collection?
Changing the following worked for me:
Manually set the current store:
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
Save each collection independently.
foreach ($collection as $entry) {
$entry->save();
}
EDIT:
Note the Magento API has changed significantly since I first asked this question ~2.5 years ago - this answer may no longer apply.
You do a foreach and save elements one by one.