erry91 Posted September 27, 2021 Share Posted September 27, 2021 Hi everyone, i need to delete all disable products, the problem is that are more than 30k I want to use a php scrip that i cron one a week, that delete this disable products only, and keep the active. I fear that if i delete products just from table ps_product, then this can cause issue with website because same id are present on ps_lang, ps_image so on... I know this script is simple for a developer(i'm not) so is there anybody can help me delete this disable products from website? Greeting from Enrico. Link to comment Share on other sites More sharing options...
ps8modules Posted September 28, 2021 Share Posted September 28, 2021 Link to comment Share on other sites More sharing options...
hshaker Posted September 28, 2021 Share Posted September 28, 2021 Il y a 15 heures, WebSoft a dit : For images Link to comment Share on other sites More sharing options...
hshaker Posted September 28, 2021 Share Posted September 28, 2021 (edited) Il y a 16 heures, WebSoft a dit : Hy, Try ('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT 10 ') You can change limite and you can add other tables Edited September 28, 2021 by hshaker (see edit history) Link to comment Share on other sites More sharing options...
erry91 Posted September 29, 2021 Author Share Posted September 29, 2021 10 hours ago, hshaker said: active Hi man, thanks so much for reply. I need to delete disable so te corret one is this? ('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `disable` = 0 ORDER BY `id_product` DESC LIMIT 10 '). Another question is, which table i have to delete to correct deleting products? only ps_product or other tables? Regards from Enrico. Link to comment Share on other sites More sharing options...
hshaker Posted September 29, 2021 Share Posted September 29, 2021 (edited) il y a 15 minutes, erry91 a dit : Hi man, thanks so much for reply. I need to delete disable so te corret one is this? ('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `disable` = 0 ORDER BY `id_product` DESC LIMIT 10 '). Another question is, which table i have to delete to correct deleting products? only ps_product or other tables? Regards from Enrico. 😬 You will go deleting all product NOT disable with this code Edited September 29, 2021 by hshaker (see edit history) Link to comment Share on other sites More sharing options...
hshaker Posted September 29, 2021 Share Posted September 29, 2021 ps_product Link to comment Share on other sites More sharing options...
ps8modules Posted September 29, 2021 Share Posted September 29, 2021 (edited) ATTENTION !!! Don't do this. You will not delete pictures, etc. I gave you a link to a ready-made solution, I don't understand why you are giving another solution here? <?php require_once('./config/config.inc.php'); $limit = 10; $res = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `active` = 0 ORDER BY `id_product` DESC LIMIT '.$limit); $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $i = 0; if ($res) { foreach ($res as $row) { echo "<p>(".date('Y/m/d H:i:s').") Deleting product with ID <b>".$row['id_product']."</b>..."; $p = new Product($row['id_product']); if(!$p->delete()) { echo " <span style='color: red'>Error deleting this product!</span></p>"; } else { echo " <span style='color: green'>DELETED</span></p>"; } $i++; } } if ($i == $limit) { echo '<script type="text/javascript">setTimeout(function(){window.top.location="'.$actual_link.'"} , 500);</script>'; } PHP file (save as Prestashop root folder) and call URL http://your-shop.com/masive-delete-inactive-product.php masive-delete-inactive-product.php Edited September 29, 2021 by WebSoft (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now