brandoneilers Posted March 3, 2006 Posted March 3, 2006 Here's my problem. I am building a recipe website with a few other people for a software engineering project. Some recipes will be put in multiple categories. I have done this by using the copy to feature and linked product option in the admin panel. It works fine if you click on the product in the product listing page, but if you click on a linked product in the new products box (new recipes box on my page) then it goes to the wrong category. It is going to the copy of the product. I absolutely did a linked product and not a duplicate. I know it has to do something with the select statements for the database, but I am not a pro at that. Please visit this link if you would like to view the problem. Click on the sugar cookie frosting product in the New Recipes box and watch the page jump from Holiday Food to Desserts. It should stay in the go to the category that contains that in Holiday Food. Please help me. http://cookingfor.us/catalog/index.php?cPath=28 Any help or feedback on the site will be greatly appreciated.
brandoneilers Posted March 6, 2006 Author Posted March 6, 2006 Anyone have any ideas? Visit the site and watch the current category you are in. When you click some product that is linked in the New Recipes Box, it jumps out to a different category. Please help if you can.
Guest Posted March 7, 2006 Posted March 7, 2006 get the code I posted here http://www.oscommerce.com/forums/index.php?showtopic=116264 place it in the catalog\includes\functions\general.php then open your catalog\includes\modules\new_products.php, locate this code: 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))); change it to this: 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '&cPath=' . tep_get_product_path($new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));
brandoneilers Posted March 8, 2006 Author Posted March 8, 2006 Unfortunately, this did not help me. I see that you added the cPath to the link when it is clicked, but it still goes to the most recent copy to spot. Say I have a recipe in Holiday Food -> Christmas, if I am in the Holiday Food category the New Recipes box displays the most recently added. But if I copy a recipe in there to somewhere else, it jumps to the category that I copied it to last. This is really a pain in the arse. I think you are on the right track, but if there was some way to specify the current category you are in so that the cPath is set accordingly that would probably work. Thanks for your help though.
Guest Posted March 8, 2006 Posted March 8, 2006 I see, in that routine where I posted on the other thread there is this code: $category_query = tep_db_query("select p2c.categories_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on (p.products_id=p2c.products_id) where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' limit 1"); change it to this: $category_query = tep_db_query("select p2c.categories_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on (p.products_id=p2c.products_id) where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' order by p2c.categories_id limit 1");
brandoneilers Posted March 9, 2006 Author Posted March 9, 2006 What you suggested brings me closer, but it is still not querying the db tables right. By adding what you gave me, a link from the new box now looks like: http://cookingfor.us/catalog/product_info....158&cPath=21_94 The 21_94 is not the right category for this box. It jumps to Desserts -> Cookies, but it should be Holiday Food -> Christmas. If there was some way to get it to bring up the right category and subcategory it would be great. For instance, this link is in the Holiday Food category section, labeled category # 28. It might work if it would look like: http://cookingfor.us/catalog/product_info....products_id=158 The problem with this is if I copied the recipe to another subcategory in the same category, it would try to access both. That would be a potentially big problem I think. Third times a charm! :D
Guest Posted March 9, 2006 Posted March 9, 2006 it will not access both it will stop on the first category/product that finds. And what I did was to alter the ordering so the oldest products/category is returned. The problem is the table can be re-arranged at any time and this can fail, I know why, but to fix you need few changes. Basically you need to put an autoincrement new column on the products_to_categories table so now that new column specifies the order of the products to categories cross-reference (in other words the order new entries are inserted). And finally remove the "order by" modification I mentioned in my last post. So every time a record is inserted, the query will automatically sort them by the new column and stop on the first one it finds. Backup the dbase of course first.
brandoneilers Posted April 2, 2006 Author Posted April 2, 2006 I want to try to figure this out again. I now believe I need to change how the new_products.php file queries the database. If someone could tell me how to get that box to only look at the subcategories in the parent category it is in, it might work. I need any help one may have. Thanks...
brandoneilers Posted April 4, 2006 Author Posted April 4, 2006 I need someone's help on this. Is there some way to only pull up the new products for the box by adding the current parent category to the query. That way by adding that in, it would only bring back products for the subcategories that it contains. I just don't know how to implement that in the catalog\includes\modules\new_products.php file.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.