Anonymous No.2 Posted April 13, 2022 Share Posted April 13, 2022 (edited) I have many duplicated rows of the same product in the Admin>Catalog>Stocks while in Admin>Catalog>Products I have only one row for the same products. I have uploaded my products using webservice, could it be the reason/bug? How to fix these duplicated rows? SELECT * FROM `ps_stock_available` WHERE `id_product` = 221 returns only one row, but in Admin>Catalog>Stocks there are many rows for this product I have removed some orphans from ps_stock_available with this SQL, but it did not help delete FROM `ps_stock_available` WHERE not exists (select p.id_product from ps_product p where p.id_product=ps_stock_available.id_product) Edited April 13, 2022 by Anonymous No.2 Added "removed some orphans"... (see edit history) Link to comment Share on other sites More sharing options...
Anonymous No.2 Posted April 19, 2022 Author Share Posted April 19, 2022 I don't have combinations. The problem is only with products which were uploaded via webservice as I understand. Link to comment Share on other sites More sharing options...
Knowband Plugins Posted April 21, 2022 Share Posted April 21, 2022 If you dont have combinations then you can delete the same by using below query "delete FROM `ps_stock_available` WHERE id_product_attribute != 0" Link to comment Share on other sites More sharing options...
Anonymous No.2 Posted April 21, 2022 Author Share Posted April 21, 2022 Searching for duplicate entries SELECT `id_product`,count(*) as cdup FROM `ps_stock_available` group by `id_product` having cdup>1 resulted in finding one product which had a non-existent attribute id. I have deleted that line, but it didn't help. I can see it seems all my products (uploaded via webservice) in Stock management are repeated 11 times. It looks like a wrong SQL join (inner instead of outer) or smth. like that somewhere, but I don't know where to look. Link to comment Share on other sites More sharing options...
musicmaster Posted April 22, 2022 Share Posted April 22, 2022 My suggestion would be to turn on profiling (https://dh42.com/blog/prestashop-debug-profiling/). Then have a look at the page that returns 11-fold and look at the queries and how many results they produce. Link to comment Share on other sites More sharing options...
Anonymous No.2 Posted April 25, 2022 Author Share Posted April 25, 2022 I cannot see an SQL with profiling turned on, instead I have found (after turning on debug) there is an ajax call to /admin..../index.php/api/stocks/ which returns duplicates and there is a column 'combination_id', but I cannot find that column 'combination_id' in the database structure. {"product_id":195,"combination_id":3500,...} This lead me to the following SQL, showing products with orphan attributes, if I understand DB structure correctly: SELECT * FROM `ps_product_attribute` where not exists (select ps_attribute.id_attribute from ps_attribute where ps_product_attribute.id_product_attribute=ps_attribute.id_attribute) ORDER BY `id_product` Deleting orphans solved the problem. Interesting, some of the demo products also had some non-existent attributes assigned in this table. 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