Php 修改Magento Cutomer模型是个好主意吗

Php 修改Magento Cutomer模型是个好主意吗,php,magento,coding-style,design-principles,Php,Magento,Coding Style,Design Principles,几天前,我发了一封邮件。请阅读这篇文章,因为这个问题是相关的 因为,我希望这个新创建的客户属性是唯一的。i、 e任何用户都不应具有与其他现有用户相同的属性。我试着自己这样做: 我在/core/Mage/Customer/Model/Resource/Customer.php中修改了\u beforeSave()函数,方法是在电子邮件验证逻辑之前添加以下代码 $result=Mage::getModel('customer/customer')->getCollection()->ad

几天前,我发了一封邮件。请阅读这篇文章,因为这个问题是相关的

因为,我希望这个新创建的客户属性是唯一的。i、 e任何用户都不应具有与其他现有用户相同的属性。我试着自己这样做:

我在
/core/Mage/Customer/Model/Resource/Customer.php
中修改了
\u beforeSave()
函数,方法是在电子邮件验证逻辑之前添加以下代码

$result=Mage::getModel('customer/customer')->getCollection()->addFieldToFilter('mobile', $customer->getMobile())->load();

        if ( is_object($result) && count($result) >= 1)
        {
            throw Mage::exception(
                'Mage_Customer', Mage::helper('customer')->__('There is already an account with this mobile number.'),
                Mage_Customer_Model_Customer::EXCEPTION_MOBILE_EXISTS
            );
        }
这样,当属性已经与现有用户关联时,我能够抛出一个异常

添加必需的代码来建模是一个好主意吗?如果我从管理面板更新Magento,此修改是否会保持不变


此外,请建议(如果有)另一种解决方案,以检查本地模块中的重复条目,而不是编辑核心模型文件。

这里您正在对核心文件进行更改。因此,升级后它将无法工作。建议使用自己的模块

您可以参考以下链接来创建基本模块


这不仅仅是链接。答案在第一段。