如何替换注册页面模板?
注册页面的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;
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]; } }
https://magento-qa.com/how-to-create-customer-without-firstname-and-lastname-in-magento-2-api
admin 编辑回答