Magento自定义模型将不允许更改数据库表 [英] Magento custom model won't allow DB table changes

查看:75
本文介绍了Magento自定义模型将不允许更改数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的自定义Magento模块遇到了问题.

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

简而言之,我为前端的客户上传创建了一个简单的模块.我用一些通用字段(例如"project_id","title"等)创建了一个新表.这很好...我可以设置模型变量,然后使用model-> save();将其保存到表中.

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();.

现在,我需要添加一个新字段或更改旧字段的名称.由于某种原因,我无法理解新字段,并且更改后的字段将无法通过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!

推荐答案

清除缓存. Magento用于读取数据库列的Zend类将缓存该信息(这样就不必为每个模型的加载/保存执行DESCRIBE了).清除缓存,Magento应该会看到新的列,并且值将开始持久保存到数据库中.

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.

这篇关于Magento自定义模型将不允许更改数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆