ptt81,
I thought this was a good idea and have now implemented it on my site ...
and I thought I would try and help you sort it out on yours.
It is a bit involved but if you know your way round php I bit it is mainly copy and pasting.
BACKUP BEFORE CHANGING ANYTHING
1. Find the in the categories.php in admin. There are two queries within an IF statement. You need to add just before the
Code:
from " . TABLE_PRODUCTS
in both of the queries.
2. Add this code
Code:
<?php
//Added to try control featured products addon
if ($products['products_featured'] == '1') {
echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setfeaturedflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
} else {
echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setfeaturedflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
}
?>
After this bit
Code:
<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $products['products_name']; ?></td>
<td class="dataTableContent" align="center">
3. At the top of the categories.php file you should find
Code:
case 'setflag':
if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
if (isset($HTTP_GET_VARS['pID'])) {
tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
}
if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
break;
Add this afterwards:
Code:
case 'setfeaturedflag':
if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
if (isset($HTTP_GET_VARS['pID'])) {
tep_set_product_featured($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
}
if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
break;
4. Then you need to open the admin/includes/functions/general.php and add the tep function. Find this:
Code:
////
// Sets the status of a product
function tep_set_product_status($products_id, $status) {
if ($status == '1') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} elseif ($status == '0') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} else {
return -1;
}
}
and add this after it:
Code:
////
// Sets the featured status of a product
function tep_set_product_featured($products_id, $status) {
if ($status == '1') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_featured = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} elseif ($status == '0') {
return tep_db_query("update " . TABLE_PRODUCTS . " set products_featured = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} else {
return -1;
}
}
5. Thats it! I think ... now you should have a little green and red button that switches the featured status on and off.
I have reused some of the code from another mod (product status on/off) - therefore, without knowing what mods you have installed there is no way for me to know if this will work for you. Although - it works for me and therefore is not impossible to achieve!
Thanks for the idea.
Regards,
Bookmarks