好的,我试图通过我的模块为注册添加字段。显然,我必须添加一个属性。因此,我的“安装脚本”实际上只是对客户实体的升级。但是,该模块已启用,但是当我刷新前端时,它不会运行我的安装脚本。我已经在前面放了一个死,看它是否击中它,也没有击中它。

我已经检查了其他7个堆栈溢出问题,每个错误都非常公然。诸如配置不匹配它所处的文件夹的内容。使用Customer_Setup作为名称。设置文件中的错误。一遍又一遍,我看了我的代码,我知道我缺少一些小东西。某个地方的某些错字.....但是我现在浪费了太多时间,所以我把它交给了你很棒的人。

config.xml

<config>
    <modules>
        <BlizzardLabs_Customer>
            <version>0.1.0</version>
        </BlizzardLabs_Customer>
    </modules>
    <global>
        <fieldsets>
            <customer_account>
                <flavour>
                  <create>1</create>
                  <update>1</update>
                </flavour>
            </customer_account>
        </fieldsets>
        <resources>
            <blizzardlabs_customer_setup>
                <setup>
                    <module>BlizzardLabs_Customer</module>
                    <class>BlizzardLabs_Customer_Model_Entity_Setup</class>
                </setup>
            </blizzardlabs_customer_setup>
        </resources>
    </global>
</config>

BlizzardLabs/customer/model/entity/setup.php

class BlizzardLabs_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup {

  public function getDefaultEntities() {
    $entities = parent::getDefaultEntities();

    // Add flavour to customer attributes
    $entities['customer']['attributes']['flavour'] = array(
        'label' => 'Ice Cream Flavour',
        'visible' => true,
        'required' => true,
    );

    return $entities;
  }

}

blizzardlabs/customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php

Mage::log('Installing BlizzardLabs_Customer');

$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'flavour', array(
    'label' => 'Ice Cream Flavour',
    'type' => 'varchar',
    'input' => 'text',
    'visible' => true,
    'required' => true,
    'position' => 1,
));

$attrs = array('flavour');

foreach ($attrs as $item) {
  $attr = Mage::getSingleton('eav/config')->getAttribute('customer', $item);
  $attr->setData('used_in_forms', array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();
}

$installer->endSetup();

echo "information added to database";

更新:我对错字表示歉意。该脚本在Blizzardlabs_customer_setup中

Code_Resource表:

+-------------------------------------+---------+
| code                                | version |
+-------------------------------------+---------+
| adminnotification_setup             | 1.0.0   |
| admin_setup                         | 0.7.1   |
| amazonpayments_setup                | 0.1.2   |
| api_setup                           | 0.8.1   |
| backup_setup                        | 0.7.0   |
| bundle_setup                        | 0.1.8   |
| catalogindex_setup                  | 0.7.10  |
| cataloginventory_setup              | 0.7.5   |
| catalogrule_setup                   | 0.7.7   |
| catalogsearch_setup                 | 0.7.6   |
| catalog_setup                       | 0.7.69  |
| checkout_setup                      | 0.9.3   |
| chronopay_setup                     | 0.1.0   |
| cms_setup                           | 0.7.8   |
| compiler_setup                      | 0.1.0   |
| contacts_setup                      | 0.8.0   |
| core_setup                          | 0.8.13  |
| cron_setup                          | 0.7.1   |
| customer_setup                      | 0.8.11  |
| cybermut_setup                      | 0.1.0   |
| cybersource_setup                   | 0.7.0   |
| dataflow_setup                      | 0.7.4   |
| directory_setup                     | 0.8.5   |
| downloadable_setup                  | 0.1.15  |
| eav_setup                           | 0.7.13  |
| enterprise_admingws_setup           | 0.0.1   |
| enterprise_catalogevent_setup       | 0.0.4   |
| enterprise_catalogpermissions_setup | 0.0.6   |
| enterprise_customerbalance_setup    | 0.0.10  |
| enterprise_enterprise_setup         | 0.0.1   |
| enterprise_giftcardaccount_setup    | 0.0.12  |
| enterprise_giftcard_setup           | 0.0.8   |
| enterprise_invitation_setup         | 0.0.3   |
| enterprise_logging_setup            | 0.1.8   |
| enterprise_pci_setup                | 0.0.3   |
| enterprise_staging_setup            | 0.1.10  |
| enterprise_websiterestriction_setup | 0.0.1   |
| eway_setup                          | 0.1.0   |
| flo2cash_setup                      | 0.1.1   |
| giftmessage_setup                   | 0.7.2   |
| googleanalytics_setup               | 0.1.0   |
| googlebase_setup                    | 0.1.1   |
| googlecheckout_setup                | 0.7.3   |
| googleoptimizer_setup               | 0.1.2   |
| ideal_setup                         | 0.1.0   |
| log_setup                           | 0.7.6   |
| newsletter_setup                    | 0.8.0   |
| oscommerce_setup                    | 0.8.10  |
| paybox_setup                        | 0.1.3   |
| paygate_setup                       | 0.7.0   |
| payment_setup                       | 0.7.0   |
| paypaluk_setup                      | 0.7.0   |
| paypal_setup                        | 0.7.2   |
| poll_setup                          | 0.7.2   |
| productalert_setup                  | 0.7.2   |
| protx_setup                         | 0.1.0   |
| rating_setup                        | 0.7.2   |
| reports_setup                       | 0.7.7   |
| review_setup                        | 0.7.4   |
| salesrule_setup                     | 0.7.7   |
| sales_setup                         | 0.9.38  |
| sendfriend_setup                    | 0.7.2   |
| shipping_setup                      | 0.7.0   |
| sitemap_setup                       | 0.7.2   |
| strikeiron_setup                    | 0.9.1   |
| tag_setup                           | 0.7.2   |
| tax_setup                           | 0.7.8   |
| usa_setup                           | 0.7.0   |
| weee_setup                          | 0.13    |
| wishlist_setup                      | 0.7.4   |
+-------------------------------------+---------+
有帮助吗?

解决方案

我认为您需要在一个名为 blizzardlabs_customer_setup. 。就像您的XML标签的名称一样 <resources> 标签。所以路径应该是 BlizzardLabs/Customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php. 。在使用修改后的路径再次尝试之前,请确保您从表中删除记录 core_resource 使用代码 blizzardlabs_customer_setup 并清除缓存。
无关。如果您与Magento EE 1.12合作,您可能会失去 mysql4 在安装脚本名称中。你可以做到 install-0.1.0.php. 。但这并不重要。它双向工作。

编辑
我已经测试过尝试运行您的脚本。我已经创建了您所描述的文件。我唯一添加的是模块声明文件: app/etc/modules/BlizzardLabs_Customer.xml 使用此内容。

<?xml version="1.0"?>
<config>
    <modules>
        <BlizzardLabs_Customer>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Customer />
            </depends>
        </BlizzardLabs_Customer>
    </modules>
</config>

一切都很好。确保您清除了缓存。确保未禁用本地模块(在 app/etc/local.xml 此标签设置为false <disable_local_modules>false</disable_local_modules>)。这就是我能想到的。

其他提示

以为我应该做正确的事情并发布此问题。在数据库中的“ core_resource”表中查看我已经看到一个 customer_setup 来自Magento Core的条目。

我的猜测这就是为什么您不能使用 blizzardlabs_customer_setup 与2个下划线无关。因此,如果您在“ core_resource”表中看不到安装,则在运行安装后的一张检查应确保您没有使用任何可能与已经存在的条目违反的东西,例如 anything_customer_setup_G

许可以下: CC-BY-SA归因
scroll top