4

このチュートリアルのステップ 2 まで正確に実行しました。実際には、彼がダウンロードできる design ディレクトリにあるファイルを除くすべてのファイルを app ディレクトリに配置しました。偶然にも、私も「学校」属性を追加しようとしていますが、これまでのところ何も変更していません。eav_attribute テーブルに「学校」が表示されます。モジュールは、system>configuration>advanced>module 出力で有効としてリストされます。キャッシュを再インデックスしてフラッシュし、ログインおよびログアウトしました。顧客を編集しようとすると、「学校」属性が表示されません。vs1.7を使用しています。このフィールドは、顧客の [アカウント情報] タブにありますか? このチュートリアルについて古いものはありますか?

これはすべてコードのダウンロードに含まれていますが、参考までに (彼は php タグの終了が欠落していたので、それらも追加しました): controllers/IndexController.php

<?php
class Excellence_Profile_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {

        $this->loadLayout();     
        $this->renderLayout();
    }
}
?>

etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Excellence_Profile>
            <version>0.1.0</version>
        </Excellence_Profile>
    </modules>
    <frontend>
        <routers>
            <profile>
                <use>standard</use>
                <args>
                    <module>Excellence_Profile</module>
                    <frontName>profile</frontName>
                </args>
            </profile>
        </routers>
        <layout>
            <updates>
                <profile>
                    <file>profile.xml</file>
                </profile>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <profile>
                <use>admin</use>
                <args>
                    <module>Excellence_Profile</module>
                    <frontName>profile</frontName>
                </args>
            </profile>
        </routers>
    </admin>
    <global>
     <fieldsets>
       <checkout_onepage_quote>
         <customer_school>
             <to_customer>school</to_customer>
         </customer_school>
       </checkout_onepage_quote>
        <customer_account>
            <school>
                <to_quote>customer_school</to_quote>
            </school>
        </customer_account>    
      </fieldsets>
    </global>
    <global>
        <fieldsets>
            <customer_account>
                 <school><create>1</create><update>1</update><name>1</name></school>
            </customer_account>
        </fieldsets>
    </global>
    <global>
        <models>
            <profile>
                <class>Excellence_Profile_Model</class>
                <resourceModel>profile_mysql4</resourceModel>
            </profile>
            <profile_mysql4>
                <class>Excellence_Profile_Model_Mysql4</class>
                <entities>
                    <profile>
                        <table>profile</table>
                    </profile>
                </entities>
            </profile_mysql4>
        </models>
        <resources>
            <profile_setup>
                <setup>
                    <module>Excellence_Profile</module>
                    <class>Mage_Customer_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </profile_setup>
            <profile_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </profile_write>
            <profile_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </profile_read>
        </resources>
        <blocks>
            <profile>
                <class>Excellence_Profile_Block</class>
            </profile>
        </blocks>
        <helpers>
            <profile>
                <class>Excellence_Profile_Helper</class>
            </profile>
        </helpers>
    </global>
</config>

モデル/エンティティ/学校

<?php
class Excellence_Profile_Model_Entity_School extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
    public function getAllOptions()
    {
        if ($this->_options === null) {
            $this->_options = array();
            $this->_options[] = array(
                    'value' => '',
                    'label' => 'Choose Option..'
            );
            $this->_options[] = array(
                    'value' => 1,
                    'label' => 'School1'
            );
            $this->_options[] = array(
                    'value' => 2,
                    'label' => 'School2'
            );
            $this->_options[] = array(
                    'value' => 3,
                    'label' => 'School3'
            );

        }

        return $this->_options;
    }
}
?>
4

1 に答える 1