conhelrad Posted December 2, 2020 Share Posted December 2, 2020 Hello, I have a weird question : what would happened if I delete products from the database ps_products directly ? My issue is this : for a stupid reason, we have a shitload (talking about 39868 products, yeah that's a lot) of products I want to delete. Problem is that a clean php script won't run a massive deletion using the Product's class delete function because it's waaaaay to long. I'm receiving getaway timeout everytime I try. Theses products can be deleted (they are not in any cart, nor ordered, they're just here, visible only in the backoffice), it's not a problem. My question is : what if I delete all of them using phpmyadmin ? What would happened ? Thank you ! Link to comment Share on other sites More sharing options...
conhelrad Posted December 4, 2020 Author Share Posted December 4, 2020 Any one ? Link to comment Share on other sites More sharing options...
Guest Posted December 5, 2020 Share Posted December 5, 2020 The products are not only in the ps_product table, but in the other 8 tables. And what about the pictures? Will you also remove it manually? You can program a script that, for example, deletes 5 products per batch and then runs again repeatedly until all products have been deleted. Link to comment Share on other sites More sharing options...
conhelrad Posted December 9, 2020 Author Share Posted December 9, 2020 Sorry @Guest I forgot to answer you. Thanks for he information. I know that the products are in many different tables, the question is : will the site brake if I do this or it will just have some informations that are not needed since the concerned products won't be in the main table ? But yes, I agree with you, the real solution would be to delete per batches. Problem is, I tried to delete some products, the condition if(delete()) worked but if I run the script again I can still find them in the database and delete them, meaning the scrip will be in a loop deleting the same 5 all products at every run. Meaning it didn't delete them (probably because some of their informations have already been deleted previously). The website is a mess but can't reset everything now. Link to comment Share on other sites More sharing options...
El Patron Posted December 9, 2020 Share Posted December 9, 2020 my advice as always, is to create a test system of your shop...there you can delete the products via db...and test...then all your questions will be answered... Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2020 Share Posted December 10, 2020 This is exactly the case when you do not have to reach into the database and change anything there. How can we advise you if we do not see in which table the products are deleted and in which table the products still exist? Where is your SQL query that you used, or where is your entire PHP code that you used to remove the products? If you don't put all the information here, we can't advise you, because there are many solutions. Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2020 Share Posted December 10, 2020 I need to find out from the ps_product table which products exist there and do not exist in the ps_product_shop table: SELECT a.`id_product` FROM `ps_product` a WHERE a.`id_product` NOT IN (SELECT b.`id_product` FROM `ps_product_shop` b) GROUP BY a.`id_product`; I need to find out from the ps_product_shop table which products exist there and do not exist in the ps_product table: SELECT a.`id_product` FROM `ps_product_shop` a WHERE a.`id_product` NOT IN (SELECT b.`id_product` FROM `ps_product` b) GROUP BY a.`id_product`; One or the other query will give you a list of product ids that are not removed correctly! Link to comment Share on other sites More sharing options...
conhelrad Posted December 14, 2020 Author Share Posted December 14, 2020 Thank you @4you.software ! I'll have a look at these queries, they seem quite useful. The SQL I was using was just a query to list products with specific manufacturer since it's how these products (the ones I wanted to delete) can be listed. Once they are listed, I was using the product class function delete() (which seems to work since I verify it with a condition) but as I said, it didn't really work, there were still existing in the ps_product tab. Maybe because they have been wrongly deleted before. I'll have a look at your queries and will run a script that will delete by batches. Thanks a lot ! Link to comment Share on other sites More sharing options...
musicmaster Posted December 15, 2020 Share Posted December 15, 2020 Most important thing when deleting just one table: do not use the TRUNCATE command. It will reset the auto-increase of the product id and that way you will clash with the tables that you didn't empty. 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