Php Magento 1.9:sql脚本未运行
基本上我想做的是:我想为客户实体定制一些属性。为了在db中添加这些字段,我正在执行脚本 我尝试了很多&很多调整和方法,但我无法解决SQL脚本错误。 其中重要的一点是:它在Php Magento 1.9:sql脚本未运行,php,sql,magento,magento-1.9,Php,Sql,Magento,Magento 1.9,基本上我想做的是:我想为客户实体定制一些属性。为了在db中添加这些字段,我正在执行脚本 我尝试了很多&很多调整和方法,但我无法解决SQL脚本错误。 其中重要的一点是:它在core\u资源表中进行输入。 我的脚本在核心资源中输入 我根据这个进行了扩展 非常感谢您的帮助 我的扩展结构 这是我的编码部分 模块的配置文件 <?xml version="1.0"?> <config> <modules> <StackExchange2_C
core\u资源
表中进行输入。
我的脚本在核心资源
中输入
我根据这个进行了扩展
非常感谢您的帮助
我的扩展结构
这是我的编码部分
模块的配置文件
<?xml version="1.0"?>
<config>
<modules>
<StackExchange2_Customer>
<version>0.1.0</version>
</StackExchange2_Customer>
</modules>
<global>
<resources>
<stackExchange2_customer_setup>
<setup>
<module>StackExchange2_Customer</module>
<class>StackExchange2_Customer_Model_Resource_Mysql4_Setup</class>
<!-- <class>StackExchange2_Customer_Sql</class>-->
</setup>
<!--Mew node-->
<connection>
<use>core_setup</use>
</connection>
</stackExchange2_customer_setup>
<!--as per sOverflow-->
<stackExchange2_customer_write>
<connection>
<use>core_write</use>
</connection>
</stackExchange2_customer_write>
<stackExchange2_customer_read>
<connection>
<use>core_read</use>
</connection>
</stackExchange2_customer_read>
</resources>
</global>
</config>
0.1.0
StackExchange2\u客户
StackExchange2\u客户\u模型\u资源\u Mysql4\u设置
核心单元设置
核心写入
核心读取
Setup.php
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//Mage_Eav_Model_Entity_Setup
class StackExchange2_Customer_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup{
}
<?php
//echo "in script";die;
$installer = $this;
echo "hi123";
$installer->startSetup();
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//attr1
$installer->addAttribute('customer','name_of_child', array(
'type' => 'varchar',
'label' => 'Name of child',
'input' => 'text',
'position' => 120,
'required' => false,//or true
'is_system' => 0,
));
$attribute1 = Mage::getSingleton('eav/config')->getAttribute('customer', 'name_of_child');
//
$attribute1->setData('used_in_forms', array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit',
));
//
$attribute1->setData('is_user_defined', 0);
//
$attribute1->save();
Mage::log(__FILE__ . 'Update installed.');
$installer->endSetup();
添加以下内容
<resources>
<stackExchange2_customer_setup>
<setup>
<module>StackExchange2_Customer</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</stackExchange2_customer_setup>
<stackExchange2_customer_write>
<connection>
<use>core_write</use>
</connection>
</stackExchange2_customer_write>
<stackExchange2_customer_read>
<connection>
<use>core_read</use>
</connection>
</stackExchange2_customer_read>
</resources>
StackExchange2\u客户
Mage_Eav_Model_Entity_设置
核心单元设置
核心写入
核心读取
您需要在设置中添加Mage\u Eav\u Model\u Entity\u Setup
类,以便添加任何属性。最后我解决了它:)
现在,在扩展适当的类(Mage\u Customer\u Model\u Entity\u Setup
)后,它就可以工作了
那么你的意思是我应该使用Mage\u Eav\u Model\u Entity\u设置
而不是Mage\u Customer\u Model\u Entity\u设置
但是为什么呢?你也可以使用它,因为Mage\u Customer\u Model\u Entity\u设置扩展了Mage\u Customer\u Model\u资源设置,从而扩展了Mage\u Eav\u Model\u Entity\u设置。我通常使用Mage_Eav_Model_Entity_设置。但为什么它只在本地主机上工作而不在live上工作?有什么想法吗?这是给任何错误或根本没有运行脚本?请阅读我的问题,并阅读更新。现在它工作得很好!:)添加列等,但有些在live server上不起作用:(所有数据都是相同的!知道为什么吗?
class StackExchange2_Customer_Model_Resource_Mysql4_Setup extends Mage_Customer_Model_Entity_Setup{
}