当我们使用Magento的export功能时候,跳转过去,一直loading,最后变成500 error。这让人很抓狂,通过Google搜索,终于找到解决方案,现分享给大家。

Example of the error:

500 Server Error
A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.

Sometimes export script just freeze without any error at all. This is quite common issue on hostings, which server configuration is not optimized for Magento. Usually hosting companies blame Magento, however this is not correct! We have several clients on Turnkeye hosting who come to us only because of this error 500 on their old hostings. The main reason of the error 500 is that FCGI process is timing out. However if you increase timing, it will not resolve the issue in many cases. In order to fix the issue completely your hosting server must support suPHP.

If you use old version of Magento, e.g. version 1.4.1.1 you can additionaly optimize export script. After optimization you will be able to export products faster, during several minutes instead of hours. Besides it will decrease the memory usage during exporting process.

To apply the patch, open the /lib/Varien/Db/Select.php and replace this part of the code:

public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
	parent::__construct($adapter);
	self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
	self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
}

With this optimized version:

public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
	parent::__construct($adapter);
	if (!in_array(self::STRAIGHT_JOIN_ON, self::$_joinTypes)) {
		self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
		self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
	}
}

Note that this solution is for old version of Magento, Magento 1.4.2.x is already contain this patch.