如何替换注册页面模板?

1.75K 浏览M2交流区magento2.4.3 注册

如何替换注册页面模板?

1、版本2.4.3

2、想去除注册页面的firstname 于 lastName

已回答
0

注册页面的firstname 与 lastName都是必填项。

有2种方法

1,把firstname 与 lastName改成非必填并隐藏起来

UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 5;
UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 7;
UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 5; UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 7;
UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 5;
UPDATE `eav_attribute` SET `is_required` = ‘0’ WHERE `eav_attribute`.`attribute_id` = 7;

https://medium.com/medvine/magento-2-dont-require-first-name-last-name-on-registration-4ec5d4d21059

2,给firstname 与 lastName默认值并隐藏起来

<?php
namespace StackExchange\Magento\Plugin;
use Magento\Customer\Api\Data\CustomerInterface;
class AccountManagementPlugin
{
public function beforeCreateAccount(
\Magento\Customer\Api\AccountManagementInterface $subject,
CustomerInterface $customer,
$password = null,
$redirectUrl = ''
){
// Set dump value to - to firstName and last Name
if($customer->getFirstname() == null){
$customer->setFirstname('-');
}
if($customer->getLastname() == null){
$customer->setLastname('-');
}
return [$customer,$password,$redirectUrl];
}
}
<?php namespace StackExchange\Magento\Plugin; use Magento\Customer\Api\Data\CustomerInterface; class AccountManagementPlugin { public function beforeCreateAccount( \Magento\Customer\Api\AccountManagementInterface $subject, CustomerInterface $customer, $password = null, $redirectUrl = '' ){ // Set dump value to - to firstName and last Name if($customer->getFirstname() == null){ $customer->setFirstname('-'); } if($customer->getLastname() == null){ $customer->setLastname('-'); } return [$customer,$password,$redirectUrl]; } }
<?php
namespace StackExchange\Magento\Plugin;

use Magento\Customer\Api\Data\CustomerInterface;

class AccountManagementPlugin 
{
    public function beforeCreateAccount(
        \Magento\Customer\Api\AccountManagementInterface $subject,
        CustomerInterface $customer,
        $password = null,
        $redirectUrl = ''
    ){
        // Set dump value to - to firstName and last Name
        if($customer->getFirstname() == null){
            $customer->setFirstname('-');
        }
        if($customer->getLastname() == null){
            $customer->setLastname('-');
        }       
        return [$customer,$password,$redirectUrl];
    }
}

https://magento-qa.com/how-to-create-customer-without-firstname-and-lastname-in-magento-2-api

编辑回答
0
您正在查看1个回答中的1个,单击此处查看所有回答。