そこで、下記のサイトで紹介されていた方法で対応を行いました。
(素晴らしい情報、ありがとうございます!)
Magentoの住所でフリガナが保存されない
上記のサイトにあるように、まずは下記のExtensionを導入します。
PepMaq_Japan_Furigana
または
PepMaq_Japan_Package14
(上記を含めたパッケージ)
これはフリガナ機能を追加する素晴らしい拡張なのですが
残念ながら対応バージョンがv1.4となっており、
v1.5.1.0に導入するには修正が必要になります。
エクステンションを導入すると、フリガナのフォームが追加されます。
ただ、そのままだとフリガナを入力してもDBに保存されないため
下記の修正を行います。
* デフォルトのデザインパッケージの場合
app/design/frontend/base/default/template/customer/form
register.phtml
このファイルの最後に下記を追加
<?php
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'firstnamekana');
$attribute->setData('used_in_forms',
array(
'checkout_register',
'customer_account_edit',
'customer_account_create',
'adminhtml_customer'
));
$attribute->save();
?>
<?php
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'lastnamekana');
$attribute->setData('used_in_forms',
array(
'checkout_register',
'customer_account_edit',
'customer_account_create',
'adminhtml_customer'
));
$attribute->save();
?>
<?php
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer_address', 'firstnamekana');
$attribute->setData('used_in_forms',
array(
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address'
));
$attribute->save();
?>
<?php
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer_address', 'lastnamekana');
$attribute->setData('used_in_forms',
array(
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address'
));
$attribute->save();
?>
次に、この処理を実行するために
フロントエンドのマイアカウントからユーザーを一度新規作成します。
レジに進んだ時のユーザー登録ではここを通らないのでだめ。
この時点でDBに登録できるようになっているので
上記で追加したregister.phtmlの処理を削除(元に戻す)します。
一度処理を行えば良いので、エクステンションのインストール時など
本当はもっと別のところで処理するべきなのでしょうが、
Magentoの仕組みがまだよくわかっていないため暫定対処しておきます。
また、このままでは日本語以外の言語設定でユーザー登録時に
カナ用フィールドが表示されないため、フリガナが必須である
アラートが表示され登録できません。
そのため、DBの設定を変更して必須ではなくします。
eav_attributeテーブルのattribute_codeが
firstnamekana
lastnamekana
となっているレコード(2個ずつ、計4個)の
is_requiredフィールドを0に設定します。
フリガナはフォームで入力チェックが行われるため
これで日本語環境時は必須、他言語環境時は不要となりました。
ただ、この時点でもまだ下記の問題点があります。
- カナはアカウント情報用と住所情報用の2種類があるが、
ユーザーが登録する画面によって片方しか登録されない
- 管理画面の顧客情報でカナの表示順がバラバラ
これらについては別途記載したいと思います。
0 comments:
Post a Comment