-
-
Save matchaxnb/ecf52cf22a158dd70444 to your computer and use it in GitHub Desktop.
<?php | |
define('_PS_ROOT_DIR_', '/path/to/prestashop/root'); | |
define('_PS_ADMIN_DIR_', _PS_ROOT_DIR_.'admin_folder'); | |
require(_PS_ADMIN_DIR_.'/../config/config.inc.php'); | |
require(_PS_ADMIN_DIR_.'/functions.php'); | |
class Employee2 extends EmployeeCore | |
{ | |
public function isSuperAdmin() | |
{ | |
return true; | |
} | |
public function isLoggedBack() | |
{ | |
return true; | |
} | |
} | |
class AdminImagesController extends AdminImagesControllerCore | |
{ | |
function regenerate() | |
{ | |
$this->_regenerateThumbnails('all', true); | |
} | |
} | |
$context = Context::getContext(); | |
$context->employee = new Employee2(1); | |
//print_r($context); | |
$aic = new AdminImagesController(); | |
echo "Starting regeneration\n"; | |
$aic->regenerate(); | |
echo "Done regenerating\n"; | |
?> |
Great job!
Could you update the script for prestop 1.7.6.x?
It works also for 1.7.6.x. Do you have problem? Could you paste your error messages?
I am sorry for the stupid question, but how do I run this code in Prestashop ?
You put it somewhere on the server and call it using a cronjob. I'm happy to see people using that snippet.
Thank you for answering. I am happy that we have people like you that wants to be usefull to other people like me. =) So, you mean all I need to do is to upload this file into a folder on my root and create a cron job calling this exact file path(for example, https://mysite.com/folder/regenerate-images.php) ? No need to change anything on the code ? Just wanna make sure I did right. Thank you, again. ;)
Great job!
Could you update the script for prestop 1.7.6.x?It works also for 1.7.6.x. Do you have problem? Could you paste your error messages?
Hello!
I have this error on prestashop 1.7.6.7:
PHP Warning: require(/path/to/prestashop/rootadmin_folder/../config/config.inc.php): failed to open stream: No such file or directory i n /home/myuser/www/mysite/regenerate-images.php on line 5
PHP Fatal error: require(): Failed opening required '/path/to/prestashop/rootadmin_folder/../config/config.inc.php' (include_path='.:/u sr/share/pear:/usr/share/php') in /home/myuser/www/mysite/regenerate-images.php on line 5
Thank you for this snippet ! I was really bothered by Prestashop not having a native bulk thumbs regeneration for big ecommerce... You saved my day :)
@evgenij-sobolev, you have an error because you need to change the 2 first lines.
The first one needs to point to the root folder (from the location of your file).
Same thing for the admin folder, you have to rename it as it is in your prestashop install (admin123xyz...) ;)
I'm actually amazed this snippet still works after all these years. :)
Hi, thanks for the script any idea to limit the rgeneration process only to some product_id?
Made my day.
If you are gonna use this, and you gonna place it somewhere under your public_html/http_docs/whatever public folder accessible over http, you should add that bit on top of the script, as otherwise you may be introducing a security issue on your server:
if (php_sapi_name() !== 'cli') {
die();
}
THANK YOU SO MUCH
regenerate-images.php works on Prestashop 1.7.8.9
Thank you++++
Hi everybody, does someone has the same kind of code for PrestaShop 8.1 ?
Hey,
I've not developed anything for Prestashop in years. Feel free to fork and to integrate that elsewhere :) it's been a pleasure to serve y'all.
Great job!
Could you update the script for prestop 1.7.6.x?