|
魔扣币兑换比例:【 50以下 : ¥1 = 10 魔扣币 】丨【 50 - 100 :¥1 = 20 魔扣币】丨【 100以上:¥1 = 30 魔扣币 】
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这近发现,有些站长的口味不一样,能让产品的URL能支持大小写访问。
如:
默认地址是:http://www.morko.net/abc.html
现在要求:http://www.morko.net/ABC.html,也能访问。
在这种情况下Magento默认是不支持的。那怎么办?
首先找到:app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php,这个文件的public function loadByRequestPath(Mage_Core_Model_Url_Rewrite $object, $path)方法,大概在134行。
修改这个方法里面的一行代码就可以了。
在158行的样子,找到:if (!array_key_exists($item[‘request_path’], $mapPenalty))改成
if (!array_key_exists(strtolower($item[‘request_path’]), array_change_key_case($mapPenalty)))就可以了。
完整代码:
- public function loadByRequestPath(Mage_Core_Model_Url_Rewrite $object, $path)
- {
- if (!is_array($path)) {
- $path = array($path);
- }
- $pathBind = array();
- foreach ($path as $key => $url) {
- $pathBind['path' . $key] = $url;
- }
- // Form select http://www.hicoogle.com
- $adapter = $this->_getReadAdapter();
- $select = $adapter->select()
- ->from($this->getMainTable())
- ->where('request_path IN (:' . implode(', :', array_flip($pathBind)) . ')')
- ->where('store_id IN(?)', array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId()));
- $items = $adapter->fetchAll($select, $pathBind);
- // Go through all found records and choose one with lowest penalty - earlier path in array, concrete store
- $mapPenalty = array_flip(array_values($path)); // we got mapping array(path => index), lower index - better
- $currentPenalty = null;
- $foundItem = null;
- foreach ($items as $item) {
- if (!array_key_exists(strtolower($item['request_path']), array_change_key_case($mapPenalty))) { //修改这里就可以了。
- continue;
- }
- $penalty = $mapPenalty[$item['request_path']] << 1 + ($item['store_id'] ? 0 : 1);
- if (!$foundItem || $currentPenalty > $penalty) {
- $foundItem = $item;
- $currentPenalty = $penalty;
- if (!$currentPenalty) {
- break; // Found best matching item with zero penalty, no reason to continue
- }
- }
- }
- // Set data and finish loading http://www.hicoogle.com/magento-rang-chan-pin-di-url-zhi-chi-da-xiao-xie.html
- if ($foundItem) {
- $object->setData($foundItem);
- }
- // Finish
- $this->unserializeFields($object);
- $this->_afterLoad($object);
- return $this;
- }
复制代码
建议:
为了以后升级不受影响,建议把这个文件重写一下。把这个文件放到:app/code/local/Mage/Core/Model/Resource/Url/Rewrite.php,效果是一样的。这样防止升级核文件被替换,导致以前修改的功能不能使用。
|
|