If you use the Admin -> View Products -> Manage Categories feature of CubeCart to put individual products in two or more categories, you may run into a problem where there are repeated or duplicated products in a category, i.e. the same product is displayed two or more times within one of the categories.
To fix the problem apply the changes below to your store, then open the Admin -> View Products -> Manage Categories popup window and the problem will be resolved.
Version: 1.0
Files Affected:
- admin/products/extraCats.php
Instructions:
DOWNLOAD admin/products/extraCats.php from your web server.
MAKE A BACKUP copy of the file so that you can restore the backup copy if any problems arise.
EDIT admin/products/extraCats.php with a text editor.
FIND this line:
// get array of existing categories product relation ships
INSERT this block *** ABOVE *** it:
/* start mod: Prevent duplicate products in categories - by Estelle */ if ($insert || $delete) { $currentPage = currentPage(); $currentPage = str_replace('&','&',$currentPage); $currentPage = str_replace("&add=".$_GET['add'],"",$currentPage); $currentPage = str_replace("&remove=".$_GET['remove'],"",$currentPage); header("Location: ".$currentPage); exit; } /* delete any duplicates - only have to run this once but doesn't hurt to leave it here */ $db->misc("DELETE T1 FROM ".$glob['dbprefix']."CubeCart_cats_idx AS T1, ".$glob['dbprefix']."CubeCart_cats_idx AS T2 WHERE T1.cat_id = T2.cat_id AND T1.productId = T2.productId AND T1.id > T2.id"); /* end mod: Prevent duplicate products in categories - by Estelle */
SAVE the file and upload to your server.
Lastly you need to log in to the Admin area of your store, go to View Products and for any of the products click on the 'Manage Categories' link (below the category name). The problem will then instantly be resolved.
CubeCart Version: 3