Oh and I apologize in advance if the code looks slightly different from what you have as I used ZC 1.5.4 code not 1.5.3 in the below... Oh and I didn't provide a define for: IMAGE_ICON_DISCONTINUE_STATUS_ON OR IMAGE_ICON_DISCONTINUE_STATUS_OFF... These could be changed to something that exists for testing by removing DISCONTINUE_
admin/includes/modules/category_product_listing.php
find:
Code:
if (isset($_GET['search']) && !empty($_GET['search']) && $action != 'edit_category') {
// fix duplicates and force search to use master_categories_id
/*
$products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity,
p.products_image, p.products_price, p.products_date_added,
p.products_last_modified, p.products_date_available,
p.products_status, p2c.categories_id,
p.products_model,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping,
p.products_quantity_order_max, p.products_sort_order
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
. TABLE_PRODUCTS_TO_CATEGORIES . " p2c
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_id = p2c.products_id
and (
pd.products_name like '%" . zen_db_input($_GET['search']) . "%'
or pd.products_description like '%" . zen_db_input($_GET['search']) . "%'
or p.products_model like '%" . zen_db_input($_GET['search']) . "%')" .
$order_by);
*/
$products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity,
p.products_image, p.products_price, p.products_date_added,
p.products_last_modified, p.products_date_available,
p.products_status, p2c.categories_id,
p.products_model,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping,
p.products_quantity_order_max, p.products_sort_order,
p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
. TABLE_PRODUCTS_TO_CATEGORIES . " p2c
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and (p.products_id = p2c.products_id
and p.master_categories_id = p2c.categories_id)
and (
pd.products_name like '%" . zen_db_input($_GET['search']) . "%'
or pd.products_description like '%" . zen_db_input($_GET['search']) . "%'
or p.products_id = '" . zen_db_input($_GET['search']) . "'
or p.products_model like '%" . zen_db_input($_GET['search']) . "%')" .
$order_by);
} else {
$products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity,
p.products_image, p.products_price, p.products_date_added,
p.products_last_modified, p.products_date_available,
p.products_status, p.products_model,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping,
p.products_quantity_order_max, p.products_sort_order
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_id = p2c.products_id
and p2c.categories_id = '" . (int)$current_category_id . "'" .
$order_by);
}
And basically replace with:
Code:
if (isset($_GET['search']) && !empty($_GET['search']) && $action != 'edit_category') {
// fix duplicates and force search to use master_categories_id
/* $products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, p.products_model, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_quantity_order_max, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id = p2c.products_id and ( pd.products_name like '%" . zen_db_input($_GET['search']) . "%' or pd.products_description like '%" . zen_db_input($_GET['search']) . "%' or p.products_model like '%" . zen_db_input($_GET['search']) . "%')" . $order_by);
*/
$products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity,
p.products_image, p.products_price, p.products_date_added,
p.products_last_modified, p.products_date_available,
p.products_status, p2c.categories_id,
p.products_model, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping,
p.products_quantity_order_max, p.products_sort_order,
p.master_categories_id, pdd.products_id as products_discontinued
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
. TABLE_PRODUCTS_TO_CATEGORIES . " p2c
LEFT JOIN " . TABLE_PRODUCTS_DISCONTINUED . " pdd ON (pdd.products_id = p.products_id)
where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and (p.products_id = p2c.products_id and p.master_categories_id = p2c.categories_id) and ( pd.products_name like '%" . zen_db_input($_GET['search']) . "%' or pd.products_description like '%" . zen_db_input($_GET['search']) . "%' or p.products_id = '" . zen_db_input($_GET['search']) . "' or p.products_model like '%" . zen_db_input($_GET['search']) . "%')" . $order_by);
} else {
$products_query_raw = ("select p.products_type, p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_quantity_order_max, p.products_sort_order, pdd.products_id as products_discontinued from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_PRODUCTS_DISCONTINUED . " pdd ON (pdd.products_id = p.products_id) where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "'" . $order_by);
}
Then find:
Code:
<?php
if ($products->fields['products_status'] == '1') {
echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
<input type="hidden" name="flag" value="0" />
</form>
<?php
} else {
echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>"/>
<input type="hidden" name="flag" value="1" />
</form>
<?php
}
and just after it add the below highlighted after it so that it is like:
Code:
<?php
if ($products->fields['products_status'] == '1') {
echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
<input type="hidden" name="flag" value="0" />
</form>
<?php
} else {
echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>"/>
<input type="hidden" name="flag" value="1" />
</form>
<?php
}
if (!zen_not_null($products->fields['products_discontinued'])) {
echo zen_draw_form('setdiscontinueflag_products', FILENAME_CATEGORIES, 'action=setdiscontinueflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_DISCONTINUE_STATUS_ON; ?>" />
<input type="hidden" name="discontinueflag" value="0" />
</form>
<?php
} else {
echo zen_draw_form('setdiscontinueflag_products', FILENAME_CATEGORIES, 'action=setdiscontinueflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
<input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_DISCONTINUE_STATUS_OFF; ?>"/>
<input type="hidden" name="discontinueflag" value="1" />
</form>
<?php
}
In admin/categories.php
find:
Code:
case 'setflag':
if ( isset($_POST['flag']) && ($_POST['flag'] == '0') || ($_POST['flag'] == '1') ) {
if (isset($_GET['pID'])) {
zen_set_product_status($_GET['pID'], $_POST['flag']);
}
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')));
break;
and add after case 'setflag' so that it looks like:
Code:
case 'setflag':
if ( isset($_POST['flag']) && ($_POST['flag'] == '0') || ($_POST['flag'] == '1') ) {
if (isset($_GET['pID'])) {
zen_set_product_status($_GET['pID'], $_POST['flag']);
}
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')));
break;
case 'setdiscontinueflag':
if ( isset($_POST['discontinueflag']) && ($_POST['discontinueflag'] == '0') || ($_POST['discontinueflag'] == '1') ) {
if (isset($_GET['pID'])) {
zen_set_product_discontinue_status($_GET['pID'], $_POST['discontinueflag']);
}
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')));
break;
create a new file with the following folder location and name
admin/includes/functions/extra_functions/functions_products_discontinued.php procedure:
Code:
<?php
////
// Sets the status of a product
function zen_set_product_discontinue_status($products_id, $status) {
global $db;
if ($status == '1') {
return $db->Execute("delete from " . TABLE_PRODUCTS_DISCONTINUED . "
where products_id = '" . (int)$products_id . "'");
} elseif ($status == '0') {
return $db->Execute("insert into " . TABLE_PRODUCTS_DISCONTINUED . "
(products_id) values (" . (int)$products_id . ")");
} else {
return -1;
}
}
create a new file with the following folder location and name:
admin/includes/extra_datafiles/products_discontinue.php
Code:
<?php
define('TABLE_PRODUCTS_DISCONTINUED', DB_PREFIX.'products_discontinued');
SQL to create table (can be applied in tools->install sql patches):
Code:
DROP TABLE IF EXISTS products_discontinued;
CREATE TABLE products_discontinued (
products_id int(11) NOT NULL,
PRIMARY KEY (products_id)
) ENGINE=MyISAM;
SQL to remove:
Code:
DROP TABLE IF EXISTS products_discontinued;
Bookmarks