OSCA2M Posted November 18, 2010 Share Posted November 18, 2010 I've been running prestashop for a while and all of a sudden the products now lists each product twice on the product category pages. I looked in the database and each product is only there once.There is only one language in my shop db.I also tried connecting a different prestashop code base to my data and yet the products are still displayed twice.I tried running the installer tool, but it did not help. I went back to an old db from a few weeks ago and it works fine.I have a feeling its related to table configs or relationships between tables..I'm not sure if prestashop has special settings for table relationships.can any one shed some light on this subject??help is greatly appreciated!!----------------------------------------------------------------------------------keywords: double products, products shown twiceproducts show up twice for no reason? can any one please help me?? Link to comment Share on other sites More sharing options...
shokinro Posted November 19, 2010 Share Posted November 19, 2010 I think most cases this is related to your data. I am not sure where your problem is occurring. Assume you problem is occurring at category page.Here is some reference( if I encounter this problem, I will do like this).go /classes/Category.php file and find the function getProducts(..)after the sql composition, insert following one line to output the sql statement print $sql; Run your page and will see sql statement output to your browser.Then copy this SQL statement to run it at MyPhpAdmin. The sql statement must be joined with many tables. try to remove joined tables one by one from sql statement and run it again. Until you find out which table cause the duplication. Link to comment Share on other sites More sharing options...
OSCA2M Posted November 19, 2010 Author Share Posted November 19, 2010 Thanks for the guidance.I went to /classes/Category.php and found the function getProducts(..) and inserted print $sql;after the sql composition and the output of the sql statement is : -----------------------------------------------------------------------------------------------SELECT p.*, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL 60 DAY)) > 0 AS new, (p.`price` * ((100 + (t.`rate`))/100) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * ((100 + (t.`rate`))/100) * `reduction_percent` / 100)),0)) AS orderprice FROM `ps_category_product` cp LEFT JOIN `ps_product` p ON p.`id_product` = cp.`id_product` LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) LEFT JOIN `ps_category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 1) LEFT JOIN `ps_product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = 1) LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1) LEFT JOIN `ps_tax` t ON t.`id_tax` = p.`id_tax` LEFT JOIN `ps_tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = 1) LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE cp.`id_category` = 16 AND p.`active` = 1-----------------------------------------------------------------------------------------------From that i narrowed down the tables involved and realized "ps_product_lang" had duplicate entries.ps_product, ps_product_attribute, ps_category_lang, ps_product_lang, ps_image, ps_image_lang, ps_tax, ps_tax_lang, ps_manufacturerI restored that signle table and presta! fixedI can finally get some sleep Thanks again for the guidance. Link to comment Share on other sites More sharing options...
shokinro Posted November 19, 2010 Share Posted November 19, 2010 I am glad you have fixed the problem.Please mark this thread as SOLVED by adding [sOLVED] to the beginning of your first post of this thread.Have a good night(day)! 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