Mganeto 常见错误解决

来源:互联网 发布:尔雅网络课用什么软件 编辑:程序博客网 时间:2024/04/30 01:12






magento 错误解决


转自http://hi.baidu.com/wolf_62/item/a5f963ede6f168eafb42ba6a


magento安装域名出错Please enter a valid URL. Protocol is required

错误出现在magento1.5版中。

1.到网上查了一下,报错的直观原因是因为js检测输入域名不合法,于是有人提出注释掉对应的js检测,大约在505行,还有人建议浏览器禁用js就行了。这两种都不失为解决方案,但是这样的解决还会带来新问题。

安装好后前台不能注册用户,后台也不能登陆直接跳出 magento 提示页面说没有设置 cookies

问题的根本原因在于,magento不在接受localhost当做域名。

所以我们需要,第一修改host文件,添加一个虚假域名指向本机。

系统目录下找到x:/windows/system32/drivers/etc/host

在下面添加上127.0.0.1 www.testmagento.com

然后配置虚拟主机

找到apache 的apache.conf文件或者是是apache/conf/extra/httpd-vhost.conf文件 ,在下面添加上

<VirtualHost *:80>
ServerAdmin example@yourmail.com
DocumentRoot “/xampp/htdocs/magento”
ServerName www.testmagento.com
ErrorLog “logs/www.testmagento.com.error.log”
CustomLog “logs/www.testmagento.com.access.log” combined
</VirtualHost>

上面的/xampp/htdocs/magento是你的magento在服务器里面的放置位置。

然后重启apache,通过www.testmagento.com访问你的magento目录就可以安装了

2.

初次接触这个商城程序,由于需要进行二次开发,所以需要先在本地搭建好环境进行本地调试,通过SVN下载到WEB目录后访问就开始安装,在安装到网站相关设置的时候,遇到了如下的错误提示,如下图:

出现这个问题原因是PHP自动获取的域名localhost的问题,在官方论坛上找到了与我遇到一样问题的人,在回答中找到了这个问题的解决办法:
地址是:http://www.magentocommerce.com/boards/viewthread/214962/P15/#t298539
不过它的配置还并不算完整的,这里记录下自己的配置
首先获取到自己的IP,按照他的说法应该可以使用127.0.0.1,也就是环回地址,但是我还是使用能上网的IP吧,通过执行ifconfig获取到IP为:192.168.1.102
那么我执行

sudo gedit /etc/apache2/apache2.conf

编辑APACHE的配置文件文件,在尾部添加

ServerName magento.local

DocumentRoot /var/www/magento


AllowOverride All
Options All

这样配置后我们直接访问magento.local是不行的,因为我们的域名服务器不是本机,所以到这里悲剧的同学想想windows下面的设置DNS选项的作用,我开始也是直接访问的,后来出错后才想起来什么原因,呵呵,以前学得知识忘的差不多了!
这里我们再编辑

sudo vi /etc/hosts

添加一条:

192.168.1.102 magento.local

然后重启apache,这里最最重要哦!

sudo /etc/init.d/apache2 restart

可能环境不一样,看到这篇文章的朋友请自己根据自己的本地环境进行搞定
然后访问magento.local就可以在上面出错的图中看到茹下面图中的效果啦

 3

I came across with the same problem. Let me share how i over came it.                 

1. Go to js\prototype and open the file “validation.js”. (FYI : All the validation takes place through this script on both front end and back end) 

2. Find this line and remove it / Comment it     

[’validate-url’, ‘Please enter a valid URL. Protocol is required (http://, https:// or ftp://)’, function (v) { 

return Validation.get(’IsEmpty’).test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v) 

}], 

3. Now continue your installation it works like a cake !!!   

4. After your installation, Don’t forget to add it / uncomment it for validation of URLs in future 

 

Magento登陆不了后台的解决方法

安装过magento的几个版本,安装好后在登陆后台的时候都遇到了点问题,用户名和密码都输入正确,就是登陆不了后台,经过研究发现,登陆不了后台的主要是因为magento自身缓存设置的问题,解决方法如下:

magento登陆不了后台可以尝试以下几种方法解决:
方法一,用FF登陆后台,在 System—Configuration-Web-Session Cookie management....timeout 改为:86400
如果方法一不行,就用方法二
方法二:仍不能登陆请打开文件 app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
找到代码:

session_set_cookie_params( 
$this-&gt;getCookie()-&gt;getLifetime(), 
$this-&gt;getCookie()-&gt;getPath(), 
$this-&gt;getCookie()-&gt;getDomain(), 
$this-&gt;getCookie()-&gt;isSecure(),

$this-&gt;getCookie()-&gt;getHttponly()

);
替换为:

session_set_cookie_params(

$this-&gt;getCookie()-&gt;getLifetime(), 
$this-&gt;getCookie()-&gt;getPath() ,
//$this-&gt;getCookie()-&gt;getDomain(), 
//$this-&gt;getCookie()-&gt;isSecure(), 
//$this-&gt;getCookie()-&gt;getHttponly() );

这些是在网上找到的,有几个版本的magento这样做过之后问题就解决了,但是还有的这样设置过后仍登陆不了后台,于是在Google里继续找原因,终于在magento论坛里看到如下内容
magento1.4.1安装完后登录不了后台,但是密码和用户名都是正确的,解决方法:
打开 magento\app\code\core\Mage\Core\Model\Session\Abstract\varien.php
找到下面的代码,注释掉$cookieParams['domain'] = $cookie->getDomain();这行,就行了。
if (isset($cookieParams['domain'])) {
            $cookieParams['domain'] = $cookie->getDomain();
        }
结果如下
if (isset($cookieParams['domain'])) {
            //$cookieParams['domain'] = $cookie->getDomain();
        }
但是按照这个去做之后,还是出现错误,于是我把下面这段全部注释掉
//if (isset($cookieParams['domain'])) {
            //$cookieParams['domain'] = $cookie->getDomain();
   //      }

 

magento1.6 或1.7.0.0

修改app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
// session cookie params

        $cookieParams = array(

            'lifetime' => $cookie->getLifetime(),

            'path'     => $cookie->getPath(),

            'domain'   => $cookie->getConfigDomain(),

            'secure'   => $cookie->isSecure(),

            'httponly' => $cookie->getHttponly()

         );

         if (!$cookieParams['httponly']) {

            unset($cookieParams['httponly']);

             if (!$cookieParams['secure']) {

                unset($cookieParams['secure']);

                 if (!$cookieParams['domain']) {

                    unset($cookieParams['domain']);

                }

             }

         }
        if (isset($cookieParams['domain'])) {

             $cookieParams['domain'] = $cookie->getDomain();

        }

        // session cookie params

        $cookieParams = array(

            'lifetime' => $cookie->getLifetime(),

            'path'     => $cookie->getPath()

//          'domain'   => $cookie->getConfigDomain(),

//          'secure'   => $cookie->isSecure(),

//          'httponly' => $cookie->getHttponly()

        );

/*

       if (!$cookieParams['httponly']) {

            unset($cookieParams['httponly']);

            if (!$cookieParams['secure']) {

                unset($cookieParams['secure']);

                if (!$cookieParams['domain']) {

                    unset($cookieParams['domain']);

                }

            }

        }

        if (isset($cookieParams['domain'])) {

            $cookieParams['domain'] = $cookie->getDomain();

        }

*/

{{base_url}} is not recommended to use in a production environment to

遇到此问题,可以做如下调整:

Base Unsecure Url / Base Secure Url.中的

{{base_url}} 都改为:类似 http://localhost/magento.com/ , 注意:本地安装测试需在文件名中包括‘‘.’’,以防止出现后台无法登录的情况 

对于

Magento Layout Error after changing Base URL {{base_url}}的问题:

When I first login to admin menu on my Magento, I was bothered by this message at the top of my admin interface.

{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento configuration.

Well, most likely you will stumble upon this message on localhost installation. Please do not change this to uncorrect value or else… your Magento site will just break down. If you did it anyway, follow these steps:

Go to your Magento database (you can use phpmyadmin) and open core_config_data table. Then find a row which has path = ‘web/unsecure/base_url’ and change the value back to {{base_url}}. Finally, to make it works you need to clear out any cache. Go to your magento installation, and open var folder, then delete the session folder (in other word, delete /magento/var/session).

Now, if you still want to update {{base_url}}, read this articlehttp://www.magentocommerce.com/blog/comments/security-update-for-magento-base-url-configuration-value/.Well, in my opinion, Magento is premature product, so it is still fragile. You have to think twice before implement it on your production site.

参考:

http://www.ferolen.com/blog/magento-layout-error-after-changing-base-url-base_url/

http://www.magentocommerce.com/boards/viewthread/19602/P15/

Fatal error: Call to undefined method Mage_Adminhtml_Block_Widget::getrowurl()
 in [magentohome]/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php on line 1607

从Magento 1.4.0.1导出产品csv文件后,要导入到Magento 1.4.2.0的时候,在上传csv文件,保存提交后报这错误。

解决办法:修改 app/code/core/Mage/Core/Block/Template.php 这个文件,在319行后面加入函数getRowUrl,如:

public function getRowUrl($row)
    {
    return $this->getUrl('*/*/edit', array('instance_id' => $row->getId()));
    }
清缓存重新试,问题解决。

 

Fatal error: Call to a member function extend() on a non-object
in \app\code\core\Mage\Core\Model\Mysql4\Config.php on line 115

错误原因及解决办法参见:

Magento错误 - Notice: Undefined index:***app\code\core\Mage\Core\Model\Mysql4\Config.php on line 92的解决办法

里的

SET FOREIGN_KEY_CHECKS=0;
update `core_store` set store_id = 0 where code='admin';
update `core_store_group` set group_id = 0 where name='Default';
update `core_website` set website_id = 0 where code='admin';
update `customer_group` set customer_group_id = 0 where customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

执行一遍清缓存就OK。

 

Magento错误 - Notice: Undefined index:***app\code\core\Mage\Core\Model\Mysql4\Config.php
on line 92的解决办法 

今天拷站架Magento 站,又碰到了这种错:

a:4:{i:0;s:116:"Notice: Undefined index :  0  in ***\app\code\core\Mage\Core\Model\Mysql4\Config.php on line 92";i:1;s:681:"#0 ***\app\code\core\Mage\Core\Model\Mysql4\Config.php(92): mageCoreErrorHandler(8, 'Undefined index...', 'D:\chen\www\mym...', 92, Array)
#1 ***\app\code\core\Mage\Core\Model\Config.php(344): Mage_Core_Model_Mysql4_Config->loadToXml(Object(Mage_Core_Model_Config))

好吧,抽时间总结一下。。

问题原因 :

Mysql使用工具 (如PhpMyAdmin / MySQL-Front / Navicat for MySQL / SQLyogEnt等)重载转储文件(也就是重导.sql文件)的时候,默认在执行过程中遇到0值一般会生成新的序列号。

Magento的core_store表的admin的store_id为0;core_store_group表的Default的group_id也为0。

在导入.sql文件的时候,原本的0变成了新的序列号,破坏了Magento原有的数据。

解决办法 :

1,

执行一遍下面语句。
SET FOREIGN_KEY_CHECKS=0;
update `core_store` set store_id = 0 where code='admin';
update `core_store_group` set group_id = 0 where name='Default';
update `core_website` set website_id = 0 where code='admin';
update `customer_group` set customer_group_id = 0 where customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

2,

在导的.sql文件最前面加入:SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO;

补充,

Mysql的模式:NO_AUTO_VALUE_ON_ZERO这个项影响 AUTO_INCREMENT 列的处理。正常情况下,当我们向 AUTO_INCREMENT 列插入0或NULL的时候,会产生下一个序列号。而mode = NO_AUTO_VALUE_ON_ZERO的时候,只有NULL才产生新的序列号,屏蔽了0。

如此,像遇到Magento报错 - Notice: Undefined index :  \app\code\core\Mage\Core\Model\Mysql4\Config.php on line 92 这种问题就解决了。

Fatal error: Call to undefined method Mage_Adminhtml_Block_Abstract::getexceptions()
in …/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php on line 167

solution:

i just notes 167 lines

// if (!is_null(parent::getExceptions()))
// return parent::getExceptions();

and 197 lines

// parent::setExceptions($exceptions);

it can work

 

Magento Index Management Catalog URL Rewrites重写错误,添加产品前台无法显示

An error occurred while saving the URL rewrite.

Magento多店铺可能会出现上诉的这个问题!URL rewrite出错了!

怎么解决Magento URL rewrite的问题呢?

搜索找到了解决方法:

The line I commented out to actually get the indexer to work and finish was line 253 in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php

try {
$this->_getWriteAdapter()->insert($this->getMainTable(), $rewriteData);
} catch (Exception $e) {
//var_dump($e); die();
//Mage::throwException(Mage::helper(‘catalog’)->__(‘An error occurred while saving the URL rewrite.’));
}

Magento Index Management建立索引速度慢解决方

Magento产品数量不多的话这点体现不严重。但是如果产品数据在10W以上(个人经验判断),建立索引常常要一小时多或者更多。 

特此研究了下,知道Magento在Index Management这边建立索引机制 的处理步骤有: 

1)目录和导航栏的产品属性的索引建立 

2)产品价格的索引 

3)目录URL和产品URL的建立 

4)重组产品的EAV数据 

5)重组目录的EAV数据 

6)目录和产品之前的关联索引 

7)目录产品的全文搜索 

8)产品库存、产品状态 

Magento索引 过程里的这八点,我主要针对第七点来优化。具体办法是,建立脚本程序,替代Magento的这部分工作内容。

 

<?php

require_once 'app/Mage.php';

umask(0);

Mage::app( "default" );

Mage::log("开始建立搜索索引:".date("d/m/y h:i:s"));

$sql = "TRUNCATE catalogsearch_fulltext;";

$mysqli = Mage::getSingleton('core/resource')->getConnection('core_write');

$mysqli->query($sql);

$process = Mage::getModel('index/process')->load(7);

$process->reindexAll();

Mage::log("搜索索引建立完成: " .date("d/m/y h:i:s"));

?>

虽然这办法对Magento Index Management这边的速度有所帮助,但是效果有限。

使用命令行刷新Magento索引管理

当我们网站商品很多的时候,比如有几千件,我们刷新Magento的索引管理(Index Management)经常会失败。那么后台刷新不了,我们还可以通过命令行来刷新。使用命令行来刷新索引管理会极大降低系统消耗,容易成功。

我们来看下步骤,如果你在使用linux服务器,登入你的ssh客户端,切换目录到你magento根文件夹中名字是shell的文件中。

在此文件夹中输入如下命令

php

 -f indexer.php -- -reindexcatalog_url

它的意思是刷新Catalog Url Rewrites即网址重写。成功后会有成功提示,如:Catalog URL Rewrites index was rebuilt successfully

magento使用Shell刷新索引管理

我们来看下有哪些索引管理,可以使用Shell的命令行来刷新,如下:

1.catalog_product_attribute    

 Product Attributes

2.catalog_product_price        

 Product Prices

3.catalog_url                 

 Catalog Url Rewrites

4.catalog_product_flat         

 Product Flat Data

5.catalog_category_flat        

 Category Flat Data

6.catalog_category_product     

 Category Products 

7.catalogsearch_fulltext       

 Catalog Search Index 

8.cataloginventory_stock       

 Stock status

如上分别对应后每项台的索引管理。

命令执行后需要耐心等待一段时间,因你商品数量和你服务器性能决定等待多久。注意命令中reinde前一共是三个英文横线。如有代码错误提示,直接黏贴本文的命令或者 

“Catalog Search Index Index proces is working now. Please try run this process later. ”的错误解决方法

之前我在一个站导入了将近2000个左右的产品,接着我重建索引就出现了 “Catalog Search Index Index proces is working now. Please try run this process later. “的错误。

谷歌了一下找到了方法,很简单,你只需把目录 var/locks  下的文件全部删掉,然后清除缓存问题就解决了。

还有,在产品比较多的时候重建索引容易出现“ 504 Time Out ” 错误,你需把数据库执行时间稍改大点,一般默认是60 秒,改成300秒就差不多了。

关于magento There has been an error processing your request 错误解决方法

下面教大家一种方法让magento1.4 显示错误的提示,这样的话我们就可以对症下药,根据错误提示方便寻找解决答案。

Exception printing is disabled by default for security reasons.

Error log record number: 878957420286

解决方法:

复制magento根目录下 /errors/local.xml.sample 并命名为/errors/local.xml

改变magento/lib/Zend/Cache/Backend/File.php 文件里面

# protected $_options = array(

# 'cache_dir' => 'null',

# protected $_options = array(

# 'cache_dir' => 'tmp/',

然后在根目录下创建tmp文件夹.

再然后刷新前台,”There has been an error processing your request” 就没有了,出现的是错误提示的也没,然后根据错误提示方便寻找解决答案!

can't see load.gif in firefox6 

so just remove or comment the id  "#loading-mas" about <!– opacity: 0.8;–>,it will solve it