MartinWiorek Posted August 19, 2011 Posted August 19, 2011 I have a store with around 50000 products, that are in 200000 categories, this means that several products are in multiple categories, (we sell auto parts and each category group is build up like this: Make -> Model -> Year -> engine -> Products_group -> Products_subgroup -> Actual product (usually only one per category) Now is there a good way to do some sort of trackback to display "application" on the products_info.php page. Basically display all categories with a trackback to the root category for each category that the product is in. I came up with this, it's not very efficient and the sort order is wrong and I want the categories per row flipped, so I get the root category to the left and the bottom category to the right. And I would like to sort the table produced by, Make, Model, Year, Eng. now it seams to sort by categories_id. <?php //APPLICATION ?> <tr> <td class="main"><table border="0" width="100%" cellspacing="3" cellpadding="2"><tr><td class="main" colspan="2"><u>Application:</u>(enligt trädet)</td></tr> <?php if(tep_not_null($product_info['products_id'])) { $p2c_query = tep_db_query("select categories_id, products_id from products_to_categories where products_id = '" . $product_info['products_id'] . "'"); while($p2c = tep_db_fetch_array($p2c_query)){ $category_name_query = tep_db_query("select c.categories_id, c.parent_id, cd.categories_id, cd.categories_name from categories c, categories_description cd where c.categories_id ='" . $p2c['categories_id'] . "' and cd.categories_id = c.categories_id order by cd.categories_name"); while($category_name = tep_db_fetch_array($category_name_query)){ $parent_id = $category_name['parent_id']; echo '<td class="main"> ' . $category_name['categories_name'] . '</td>'; // p2c category while($parent_id != '0'){ //Backtrack to top level category $parent_name_query = tep_db_query("select c.categories_id, c.parent_id, cd.categories_id, cd.categories_name from categories c, categories_description cd where c.categories_id ='" . $parent_id . "' and cd.categories_id = c.categories_id order by cd.categories_name"); while($parent_name = tep_db_fetch_array($parent_name_query)){ echo '<td class="main" align="left" >' . $parent_name['categories_name'] . '</td>'; $parent_id = $parent_name['parent_id']; } } echo '</tr>'; } } } ?></table></td> </tr> <?php //END APPLICATION ?> Could somebody help me get this info sorted.
ГоранЂуричић Posted August 22, 2011 Posted August 22, 2011 I have a store with around 50000 products, that are in 200000 categories, this means that several products are in multiple categories, (we sell auto parts and each category group is build up like this: Make -> Model -> Year -> engine -> Products_group -> Products_subgroup -> Actual product (usually only one per category) Now is there a good way to do some sort of trackback to display "application" on the products_info.php page. Basically display all categories with a trackback to the root category for each category that the product is in. I came up with this, it's not very efficient and the sort order is wrong and I want the categories per row flipped, so I get the root category to the left and the bottom category to the right. And I would like to sort the table produced by, Make, Model, Year, Eng. now it seams to sort by categories_id. <?php //APPLICATION ?> <tr> <td class="main"><table border="0" width="100%" cellspacing="3" cellpadding="2"><tr><td class="main" colspan="2"><u>Application:</u>(enligt trädet)</td></tr> <?php if(tep_not_null($product_info['products_id'])) { $p2c_query = tep_db_query("select categories_id, products_id from products_to_categories where products_id = '" . $product_info['products_id'] . "'"); while($p2c = tep_db_fetch_array($p2c_query)){ $category_name_query = tep_db_query("select c.categories_id, c.parent_id, cd.categories_id, cd.categories_name from categories c, categories_description cd where c.categories_id ='" . $p2c['categories_id'] . "' and cd.categories_id = c.categories_id order by cd.categories_name"); while($category_name = tep_db_fetch_array($category_name_query)){ $parent_id = $category_name['parent_id']; echo '<td class="main"> ' . $category_name['categories_name'] . '</td>'; // p2c category while($parent_id != '0'){ //Backtrack to top level category $parent_name_query = tep_db_query("select c.categories_id, c.parent_id, cd.categories_id, cd.categories_name from categories c, categories_description cd where c.categories_id ='" . $parent_id . "' and cd.categories_id = c.categories_id order by cd.categories_name"); while($parent_name = tep_db_fetch_array($parent_name_query)){ echo '<td class="main" align="left" >' . $parent_name['categories_name'] . '</td>'; $parent_id = $parent_name['parent_id']; } } echo '</tr>'; } } } ?></table></td> </tr> <?php //END APPLICATION ?> Could somebody help me get this info sorted. We have practically the same problem with category listing in product_info.php Have you made any progress since January?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.