Reputation: 71
I'm running a Prestashop store for over 2 years now, since this morning the back-office is really slow.
So I used the debug-mode and I can see that initContent
is taking 12s to load... Nothing else seems wrong in the debug log. I didn't install new module or changed any parameters, B-O was working fine yesterday evening.
I've searched a bit and found some "fixes" that doesn't work for me:
I've read some other things about connexion to Prestashop's servers. Do you guys have any informations about that?
Upvotes: 2
Views: 6253
Reputation: 11
After a years of using Prestashop I think that the main problem in most cases is module "Merchant expertise" (native Prestashop) it is calling "gamification" in the modules folder. So by disabling it, everything works fine at the backend.
Upvotes: 1
Reputation: 169
Prestashop checks for module list related to back office tabs. You can see a Recommended Modules button in header toolbars of back office pages.
To disable this option create a file /override/classes/controller/AdminController.php
with the following content :
class AdminController extends AdminControllerCore
{
protected function initTabModuleList()
{
return;
}
}
Note that you will not lost other addons related functionalities.
Upvotes: 3
Reputation: 5748
I can confirm on some of my projects that Prestashop Addons check is responsible for this delay.
You can quickly fix this by disabling all connection to Prestashop servers in Tools
class.
Create a file /override/classes/Tools.php
with the following content :
<?php
class Tools extends ToolsCore {
public static function addonsRequest($request, $params = array())
{
return false;
}
}
Then delete file /cache/class_index.php
.
The limitation of the above solution is that you will lost all addons related functionalities (modules updates, themes and modules suggestions...). I'm fine with it but that might not be your case.
So instead of completely disabling addons connections you could reduce the request timeout (from 5 seconds to 2 seconds):
Create a file /override/classes/Tools.php
with the following content :
<?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;
}
}
Then delete file /cache/class_index.php
.
Upvotes: 4