Prestashop慢速后台办公室(初始内容:12000ms)
我经营一家Prestashop商店已经两年多了,因为今天早上后台工作真的很慢。 所以我使用了调试模式,我可以看到Prestashop慢速后台办公室(初始内容:12000ms),prestashop,prestashop-1.6,add-on,Prestashop,Prestashop 1.6,Add On,我经营一家Prestashop商店已经两年多了,因为今天早上后台工作真的很慢。 所以我使用了调试模式,我可以看到initContent需要12秒才能加载。。。调试日志中似乎没有其他错误。我没有安装新模块或更改任何参数,B-O昨天晚上工作正常 我搜索了一下,发现了一些不适合我的“修复”: 禁用统计模块(已禁用) 更改config/xml文件夹的权限并删除其中的文件 我读过一些关于连接到Prestashop服务器的其他内容。你们有什么消息吗 我可以在我的一些项目中确认,Prestashop插件检
initContent
需要12秒才能加载。。。调试日志中似乎没有其他错误。我没有安装新模块或更改任何参数,B-O昨天晚上工作正常
我搜索了一下,发现了一些不适合我的“修复”:
- 禁用统计模块(已禁用)
- 更改config/xml文件夹的权限并删除其中的文件
我可以在我的一些项目中确认,Prestashop插件检查是造成延迟的原因 通过在
Tools
class中禁用与Prestashop服务器的所有连接,可以快速修复此问题
创建包含以下内容的文件/override/classes/Tools.php
:
<?php
class Tools extends ToolsCore {
public static function addonsRequest($request, $params = array())
{
return false;
}
}
<?php
class Tools extends ToolsCore {
public static function addonsRequest($request, $params = array())
{
if (!self::$is_addons_up) {
return false;
}
$post_data = http_build_query(array(
'version' => isset($params['version']) ? $params['version'] : _PS_VERSION_,
'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code),
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(),
'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')
));
$protocols = array('https');
$end_point = 'api.addons.prestashop.com';
switch ($request) {
case 'native':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native';
break;
case 'native_all':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native&iso_code=all';
break;
case 'must-have':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have';
break;
case 'must-have-themes':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have-themes';
break;
case 'customer':
$post_data .= '&method=listing&action=customer&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'customer_themes':
$post_data .= '&method=listing&action=customer-themes&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'check_customer':
$post_data .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
break;
case 'check_module':
$post_data .= '&method=check&module_name='.urlencode($params['module_name']).'&module_key='.urlencode($params['module_key']);
break;
case 'module':
$post_data .= '&method=module&id_module='.urlencode($params['id_module']);
if (isset($params['username_addons']) && isset($params['password_addons'])) {
$post_data .= '&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
} else {
$protocols[] = 'http';
}
break;
case 'hosted_module':
$post_data .= '&method=module&id_module='.urlencode((int)$params['id_module']).'&username='.urlencode($params['hosted_email'])
.'&password='.urlencode($params['password_addons'])
.'&shop_url='.urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain())
.'&mail='.urlencode(isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'));
$protocols[] = 'https';
break;
case 'install-modules':
$protocols[] = 'http';
$post_data .= '&method=listing&action=install-modules';
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
break;
default:
return false;
}
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'content' => $post_data,
'header' => 'Content-type: application/x-www-form-urlencoded',
'timeout' => 2,
)
));
foreach ($protocols as $protocol) {
if ($content = Tools::file_get_contents($protocol.'://'.$end_point, false, $context)) {
return $content;
}
}
self::$is_addons_up = false;
return false;
}
}
class AdminController extends AdminControllerCore
{
protected function initTabModuleList()
{
return;
}
}
然后删除文件
/cache/class_index.php
Prestashop检查与后台选项卡相关的模块列表。您可以在后台办公页面的标题工具栏中看到推荐的模块按钮
要禁用此选项,请创建包含以下内容的文件/override/classes/controller/AdminController.php
:
<?php
class Tools extends ToolsCore {
public static function addonsRequest($request, $params = array())
{
return false;
}
}
<?php
class Tools extends ToolsCore {
public static function addonsRequest($request, $params = array())
{
if (!self::$is_addons_up) {
return false;
}
$post_data = http_build_query(array(
'version' => isset($params['version']) ? $params['version'] : _PS_VERSION_,
'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code),
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(),
'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')
));
$protocols = array('https');
$end_point = 'api.addons.prestashop.com';
switch ($request) {
case 'native':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native';
break;
case 'native_all':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native&iso_code=all';
break;
case 'must-have':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have';
break;
case 'must-have-themes':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have-themes';
break;
case 'customer':
$post_data .= '&method=listing&action=customer&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'customer_themes':
$post_data .= '&method=listing&action=customer-themes&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'check_customer':
$post_data .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
break;
case 'check_module':
$post_data .= '&method=check&module_name='.urlencode($params['module_name']).'&module_key='.urlencode($params['module_key']);
break;
case 'module':
$post_data .= '&method=module&id_module='.urlencode($params['id_module']);
if (isset($params['username_addons']) && isset($params['password_addons'])) {
$post_data .= '&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
} else {
$protocols[] = 'http';
}
break;
case 'hosted_module':
$post_data .= '&method=module&id_module='.urlencode((int)$params['id_module']).'&username='.urlencode($params['hosted_email'])
.'&password='.urlencode($params['password_addons'])
.'&shop_url='.urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain())
.'&mail='.urlencode(isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'));
$protocols[] = 'https';
break;
case 'install-modules':
$protocols[] = 'http';
$post_data .= '&method=listing&action=install-modules';
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
break;
default:
return false;
}
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'content' => $post_data,
'header' => 'Content-type: application/x-www-form-urlencoded',
'timeout' => 2,
)
));
foreach ($protocols as $protocol) {
if ($content = Tools::file_get_contents($protocol.'://'.$end_point, false, $context)) {
return $content;
}
}
self::$is_addons_up = false;
return false;
}
}
class AdminController extends AdminControllerCore
{
protected function initTabModuleList()
{
return;
}
}
请注意,您不会丢失其他与插件相关的功能。我也很满意,但它可能对其他项目有用,再次感谢您。