質問

さて、モジュールで登録にフィールドを追加しようとしています。明らかに、属性を追加する必要があります。したがって、私の「インストールスクリプト」は、実際には顧客エンティティへの単なるアップグレードです。ただし、モジュールは有効になっていますが、フロントエンドを更新すると、インストールスクリプトが実行されません。私はそれがそれを打つことさえ、そうでないかどうかを見るために、正面に死を置いた。

私は他の約7つのスタックオーバーフローの質問をチェックしましたが、それぞれのエラーはかなり露骨でした。 constitionのようなものは、その中にあるフォルダーと一致していないようなものです。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   |
+-------------------------------------+---------+
役に立ちましたか?

解決

mysql4-install-0.1.0.phpをフォルダー内に追加する必要があると思います。 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」テーブルで表示できない場合、インストールを実行した後のチェックの1つは、既存のエントリに違反する可能性のあるものを使用していないことを確認する必要があります。 anything_customer_setup_g

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top