Totally Zenned
- Join Date:
- Oct 2004
- Location:
- Southport, UK
- Posts:
- 3,644
- Plugin Contributions:
- 6
Multiple Categories Link Manager - an Improvement.
A customisation FOR admin, rather than from it.
We manage a zen-cart store for a pizza company with over 100 franchises (each franchise being a first level category) all selling the same "menu", so all products in the sub-categories are linked. Default ZC displays the Multiple Categories Link Manager using category ID's which is not particularly helpful, and I wanted to be able to see the PARENT category name (ie, in our case, the name of the franchise). Having struggled for a few hours (as I STILL don't actually understand php! :D) I have come up with a solution that works nicely. Now this may not be elegant, but I just could not get the zen_get_categories_parent_name function to work (probably due to ignorance) although by copying the content of that function into the file, I got a result.
So, for anyone who would like to do the same, firstly make a backup copy of admin/products_to_categories.php
Then edit the file and about line 650, replace echo ' <td class="dataTableContent" align="right">' . $categories_list->fields['categories_id'] . '</td>' . "\n";with echo ' <td class="dataTableContent" align="right">'. $parentName.'</td>' . "\n";NB. If you wanted to show both the Parent Category name AND the actual category ID, then use ```
echo ' <td class="dataTableContent" align="right">' . $parentName . '(' . $categories_list->fields['categories_id'] . ')</td>' . "\n";
Then at about line 638 (yes, I know it's backwards, but it made it easier to find the first line number!) find
$cnt_columns = 0;
while (!$categories_list->EOF) {
$cnt_columns++;
$cnt_columns = 0;
while (!$categories_list->EOF) {
//BOF -- To replace Category ID with PARENT category name
$lookup_query = "select parent_id from " . TABLE_CATEGORIES . " where categories_id='" . (int)$categories_list->fields['categories_id'] . "'";
$lookup = $db->Execute($lookup_query);
$lookup_query = "select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id='" . (int)$lookup->fields['parent_id'] . "'";
$lookup = $db->Execute($lookup_query);
$parentName= $lookup->fields['categories_name'];
//EOF -- To replace Category ID with PARENT category name
$cnt_columns++;
Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !