我想覆盖/扩展Mage_Core_Encryption_Model来处理旧版密码.
我正在将旧网站数据迁移到magento.我的旧网站加密方法是Sha-1.但magento在核心加密方法中使用md5 +文本.我已手动更改核心模块并正确迁移但现在我想为此创建一个自定义模块(迁移后无需加密,迁移后通过sha-1覆盖md5方法)
如何为覆盖我已更改的核心代码创建自定义模块?
Dre*_*ter 10
如果我理解正确,你需要一个模块用sha1替换Magento中的md5哈希机制吗?
我不会在这里创建一个完整的模块,而只是关键部分.如果你感兴趣的是作为一个完整的例子来引用,我在前面创建了一个模块,用你可以看到的sha512替换md5哈希 - https://github.com/drewhunter/BetterHash - 你显然需要稍微修改它以处理sha1)
所以基本上你需要覆盖hash()方法Mage_Core_Model_Encryption
您的模块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>
Run Code Online (Sandbox Code Playgroud)
然后利用重写:
文件: 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);
}
}
Run Code Online (Sandbox Code Playgroud)