2

登録 (/customer/account/create/) からフィールドを削除したい。これどうやってするの?ストアのファイルにアクセスせずに (たとえば、これらのフィールドを非表示にするなど) 方法はありますか?

4

2 に答える 2

3

DB のいくつかのフィールドを更新する必要があります。

例えば。登録フォームから姓を削除する必要があります。必須フィールドです。そこで、フィールド パラメータを変更するために、SQL 更新ファイルを使用して独自のモジュールを作成しました。

アップグレード-1.0.0.1-1.0.0.2.php

/* @var $installer Mage_Customer_Model_Entity_Setup */

$installer = $this;

$installer->startSetup();
// SELECT attribute_id, entity_type_id FROM eav_attribute where attribute_code = 'lastname'
// SELECT * FROM customer_eav_attribute where attribute_id in (SELECT attribute_id FROM eav_attribute where attribute_code = 'lastname')
$options = unserialize('a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}');

if (isset($options['min_text_length'])) unset($options['min_text_length']);

$installer->addAttribute('customer', 'lastname', array(
    'validate_rules' => serialize($options),
    'required'       => false
));

$installer->addAttribute('customer_address', 'lastname', array(
    'validate_rules' => serialize($options),
    'required'       => false
));

$installer->endSetup();

その後、html+css または js を使用してこのフィールドを非表示にする必要があります。

アップデート:

ファイル/app/design/frontend/default/YOURTHEME/template/customer/widget/name.phtmlを編集して、登録フォームを変更します。私の場合、html ブロッ​​クをコメントアウトしました。

<?php /*if ($this->showMiddlename()): ?>
        <?php $isMiddlenameRequired = $this->isMiddlenameRequired(); ?>
        <div class="field name-middlename">
            <label for="<?php echo $this->getFieldId('middlename')?>"<?php echo $isMiddlenameRequired ? ' class="required"' : '' ?>><?php echo $isMiddlenameRequired ? '<em>*</em>' : '' ?><?php echo $this->getStoreLabel('middlename') ?></label>
            <div class="input-box">
                <input type="text" id="<?php echo $this->getFieldId('middlename')?>" name="<?php echo $this->getFieldName('middlename')?>" value="<?php echo $this->escapeHtml($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> />
            </div>
        </div>
    <?php endif; */?>

    <!--<div class="field name-lastname">
        <label for="<?php echo $this->getFieldId('lastname')?>" class="required"><em>*</em><?php echo $this->getStoreLabel('lastname') ?></label>
        <div class="input-box">
            <input type="text" id="<?php echo $this->getFieldId('lastname')?>" name="<?php echo $this->getFieldName('lastname')?>" value="<?php echo $this->escapeHtml($this->getObject()->getLastname()) ?>" title="<?php echo $this->getStoreLabel('lastname') ?>" maxlength="255" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('lastname') ?>" <?php echo $this->getFieldParams() ?> />
        </div>
    </div>-->

<div class="field name-middlename">また、いくつかのクラスをandに追加することもできます<div class="field name-lastname">。このクラスには css プロパティが必要"display:none;"です。

于 2013-02-23T21:51:25.163 に答える