Magento custom model won't allow DB table changes
Asked Answered
H

3

11

I've run into an issue with a custom Magento module I've created.

In short, I created a simple module for customer uploads on the front-end. I created a new table with some generic fields like 'project_id', 'title', etc. This is all fine...I can set model variables and save them to my table using model->save();.

Just now I have the need to add a new field or change an old field's name around. For a reason that I can't understand new fields and changed fields will not get stored to via model->save(); even though I can see from my debugger that new and changed variables in my model are being set correctly. I'm hoping someone has run into this already and can shed some light on this extremely frustrating issue. My project is at a stand-still until help arrives!

Hokum answered 5/1, 2012 at 23:58 Comment(0)
I
20

Clear you cache. The Zend classes Magento uses to read database columns will cache that information (such that it's not necessary to do a DESCRIBE for each model load/save). Clear out your cache and Magento should see the new columns, and values will start persisting to the database.

Inglorious answered 6/1, 2012 at 0:34 Comment(9)
All caches have been disabled since project start, yet this works! It's the last thing I would have thought to check since they've remained disabled during production. Why would that happen?Hokum
All Magento caches have been disabled. I've never investigated too deeply, I assume it's some sort of caching going on deep in the Zend Framework, probably via the registry object. The Magento caches you enable/disable are for keys set via Magento's caching class. Since the Zend DB classes do some caching of their own, this gets missed. Chalk it up to another instance of Magento is Not Zend.Inglorious
That response works for me. Thanks for the help! I'm sure there will be many more inquiries...Hokum
Additionally, you should clear the DDL cache from the upgrade script. The reason for the cached DDL data to still be cached is because it does not fall underneath any of the tags manageable via the admin.Lawless
handy habit in developer practice is to call rm -rf var/cache/* to clear all meta caches before deployment or testingHeida
not familiar with linux command line...i assume rm is remove directory but what is -rf?Hokum
I did a little of tracing, #12205751Tiliaceous
after 1,5h hacking I started searching the web and found this post. thank you very much. cleared cache and now works. very stupid mistake :)English
Thanks Alan. Do you know whether you would want to use Flush Magento Cache or Flush Cache Storage in an environment where the file system isn't necessarily being used as the cache backend?Esotropia
P
3

Disabling cache in Magento admin panel seems not to be enough. You should delete the contents of /var/cache manually.

Palacio answered 28/5, 2013 at 17:3 Comment(0)
B
0

Run rm -rf var/cache/* from the console, as you wont be able to get through to the admin Cache Management screen

Benzine answered 5/10, 2015 at 2:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.