我想覆盖/扩展Mage_Core_Encryption_Model来处理旧密码。
我正在将旧网站的数据迁移到magento。我的旧站点加密方法是Sha-1。但magento在核心加密方法中使用md5 + text。我已经手动更改了核心模块,并正确地进行了迁移,但现在我想为此创建一个自定义模块(不加密迁移,迁移后使用sha-1覆盖md5方法)
如何为创建自定义模块来覆盖我已更改的核心代码?
发布于 2012-08-06 20:38:26
如果我理解正确的话,您需要一个模块来用sha1替换Magento中的md5散列机制。
我不会在这里创建一个完整的模块,而是简单地介绍关键部分。如果您有兴趣作为一个完整的示例参考,我前不久创建了一个模块,它用sha512替换了md5散列,您可以查看https://github.com/drewhunter/BetterHash -您显然需要稍微修改它以处理sha1)
因此从本质上讲,您需要覆盖Mage_Core_Model_Encryption的hash()方法
您的模块config.xml将需要以下内容:
app/code/local/Yourcompany/Yourmodule/etc/config.xml文件:
<?xml version="1.0"?>
<config>
<modules>
<Yourcompany_Yourmodule>
<version>1.0.0</version>
</Yourcompany_Yourmodule>
</modules>
<global>
<helpers>
<core>
<encryption_model>Yourcompany_Yourmodule_Model_Hash</encryption_model>
</core>
</helpers>
</global>
</config>然后利用重写的优势:
app/code/local/Yourcompany/Yourmodule/Model/Hash.php文件:
<?php
class Yourcompany_Yourmodule_Model_Hash extends Mage_Core_Model_Encryption
{
public function hash($data)
{
return sha1($data);
}
}https://stackoverflow.com/questions/11827717
复制相似问题