Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    May 2015
    Location
    Mississauga, Ontario, Canada
    Posts
    14
    Plugin Contributions
    0

    Default Flag discontinued products

    Hi everyone,

    i would like to have a feature in admin product list where I will be able to flag/mark products to "discontinued". The main idea here is to let my colleague know "yellow button" products are discontinued and "green button" products are active just like it does for product_status. I don't want it to interfere it with frontend and this is purely for management. I have attached mockup of how I would like it to show on admin product list.

    Click image for larger version. 

Name:	avenview_discontinued.jpg 
Views:	164 
Size:	44.4 KB 
ID:	15497

    Please advice.

    Regards,

    Fahad

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    Basically need an additional field tied to the product id that is capable of handling however many conditions desired. If it is/was just two values (green and not green) then could have a separate table that is inner joined to the data collected for that screen where data would only be present in that table if it hasbeen "discontinued" and thenwhen the product is "removed" (no longer have stock) then that entry can be removed and the disabled status could cause whatever color change is/was necessary...

    That's just my thought on implementation. A little more involved than simply adding that field to the products table, but at least that way is divorced from affecting the base database structure..
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    May 2015
    Location
    Mississauga, Ontario, Canada
    Posts
    14
    Plugin Contributions
    0

    Default Re: Flag discontinued products

    Thanks mc12345678 for replying. I almost forgot about this post. How can I implement this feature? I just want two values (green/red). It doesn't have to link to products status at all as it is purely for administrators. Please advise.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    Quote Originally Posted by fahadali View Post
    Thanks mc12345678 for replying. I almost forgot about this post. How can I implement this feature? I just want two values (green/red). It doesn't have to link to products status at all as it is purely for administrators. Please advise.
    So conceptual design that I had for this was:
    1. Separate table to be created/destroyed by the "plugin" installation/removal.
    2. Table contains the products_id for products that are discontinued (thought is that upon discontinue, at some point the product would be deleted and at that time so would the entry in the table when written correctly.) Alternatively if it seems as if the discontinued product will outnumber the active product the usage of the table could be reversed, but the idea being that its contents be 1) minimized and 2) in some regards normalized.
    3. Assume that the status of a product being discontinued would not only be on the catalog listing but also something controllable in the admin's product information page as well. If not for this specific instance, it would seem prudent for total design and usage by others.
    4. Clicking on the discontinued status button would shift its image to the alternate view. (if someone wanted more "phases" then they could cycle from one to the next back to the beginning, and if that was the case, then the above table would actually need an additional column and then would track the status/condition for all product not just the ones discontinued. The entry would still be deleted/removed upon deletion of the product.)

    Item 3 above would require modification of at least two each files for each product type that is in the store or an applicable notifier/observer combination so that the data from the table could be collected, displayed, and subsequently saved while editing the product information.
    Item 4 would require a modification similar to a few other plugins make to the template file that provides the products listing. Ie. Image Handler modifies to provide a clickable link and I've seen a few other plugins that do this. But effectively all the same thing with the status change code being borrowed from the existing product status button, so that isn't too much of an issue.

    The row/table data could go directly into the products table; however, it seems that it would be wiser to use the sql database to do what it does and to maintain the table as clutter free as possible, even if in producing this one column would include overhead for a new table, whereas if two columns are needed (multi-status) then the products_id would be a column that already exists in several other locations.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    May 2015
    Location
    Mississauga, Ontario, Canada
    Posts
    14
    Plugin Contributions
    0

    Default Re: Flag discontinued products

    Quote Originally Posted by mc12345678 View Post
    So conceptual design that I had for this was:
    1. Separate table to be created/destroyed by the "plugin" installation/removal.
    2. Table contains the products_id for products that are discontinued (thought is that upon discontinue, at some point the product would be deleted and at that time so would the entry in the table when written correctly.) Alternatively if it seems as if the discontinued product will outnumber the active product the usage of the table could be reversed, but the idea being that its contents be 1) minimized and 2) in some regards normalized.
    3. Assume that the status of a product being discontinued would not only be on the catalog listing but also something controllable in the admin's product information page as well. If not for this specific instance, it would seem prudent for total design and usage by others.
    4. Clicking on the discontinued status button would shift its image to the alternate view. (if someone wanted more "phases" then they could cycle from one to the next back to the beginning, and if that was the case, then the above table would actually need an additional column and then would track the status/condition for all product not just the ones discontinued. The entry would still be deleted/removed upon deletion of the product.)

    Item 3 above would require modification of at least two each files for each product type that is in the store or an applicable notifier/observer combination so that the data from the table could be collected, displayed, and subsequently saved while editing the product information.
    Item 4 would require a modification similar to a few other plugins make to the template file that provides the products listing. Ie. Image Handler modifies to provide a clickable link and I've seen a few other plugins that do this. But effectively all the same thing with the status change code being borrowed from the existing product status button, so that isn't too much of an issue.

    The row/table data could go directly into the products table; however, it seems that it would be wiser to use the sql database to do what it does and to maintain the table as clutter free as possible, even if in producing this one column would include overhead for a new table, whereas if two columns are needed (multi-status) then the products_id would be a column that already exists in several other locations.
    Thank you for quick response! Okay so I don't want it to interact with any "out of stock/discontinued" products as we don't want the products to vanish. It will be purely used to flag products. The idea is to let administrators know which product is discontinued just like in point 4. I believe I will have to create new table in database "product_discontinueflag" and then edit some sort of catalog page view file in admin folder. The problem is I dont know how to achieve this. Please advise.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    Quote Originally Posted by fahadali View Post
    Thank you for quick response! Okay so I don't want it to interact with any "out of stock/discontinued" products as we don't want the products to vanish. It will be purely used to flag products. The idea is to let administrators know which product is discontinued just like in point 4. I believe I will have to create new table in database "product_discontinueflag" and then edit some sort of catalog page view file in admin folder. The problem is I dont know how to achieve this. Please advise.
    There was no plan for any interaction with the out-of-stock/disabled status. The discussion of deletion was related to ensuring that when/if a product was deleted and it was tracked in the table, then it should be removed from the table otherwise the table would unnecessarily grow and never get cleaned up.

    I have what seems to be the code to facilitate at least the basic implementation of at least showing the indicator while navigating the admins catalog. Adding the field/data to the product information page(s) will take a little more. I'll get it up in a little bit on this thread. Doesn't yet add the option into the product info page for admin control while editing the product, but is not far from that capability. Just need to help identify where to insert the code specifically.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    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;
    Last edited by mc12345678; 11 Sep 2015 at 02:57 AM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    Had an opportunity to apply the below code and discovered an error in the first section of code (admin/includes/modules/category_product_listing.php). Also discovered though should have known better, need to run the sql at the end of the previous post before attempting to access this functionality in the admin otherwise will receive a sql error need to reload the page notification.

    The corrected code is:

    Code:
    $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 LEFT JOIN " . TABLE_PRODUCTS_DISCONTINUED . " pdd ON (pdd.products_id = p.products_id), " . 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, pdd.products_id as products_discontinued 
    from " . TABLE_PRODUCTS . " p 
    LEFT JOIN " . TABLE_PRODUCTS_DISCONTINUED . " pdd ON (pdd.products_id = p.products_id), 
    " . 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);
    }
    Quote Originally Posted by mc12345678 View Post
    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);
    }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Flag discontinued products

    FYI, the following could be applied to provide the "popup" text when hovering over the new option in the categories menu:

    create a new file with the following path:
    admin/includes/languages/english/extra_definitions/products_discontinue.php

    with the following contents:

    Code:
    <?php
    define('IMAGE_ICON_DISCONTINUE_STATUS_ON', 'Product *NOT* Discontinued');
    define('IMAGE_ICON_DISCONTINUE_STATUS_OFF', 'Product Discontinued');
    For the first option, perhaps could say Product Available instead or some other "meaningful" text... The use of *NOT* was a simple go/no-go choice..

    The above code really could be used for any two state internal usage. It is currently written with the thought that the number of active/available product that will be in the database outweighs the number of discontinued product in the database. If this is considered backwards, then it would be necessary to implement a few things differently (ie. add product to the table that are still available). Regardless either one of these could mostly be done with SQL commands... I will say and I've thought about this a little more that tools such as Easy Populate would require modification to include this particular attribute as the switch was not added to the products table which is heavily referenced in EasyPopulate.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    May 2015
    Location
    Mississauga, Ontario, Canada
    Posts
    14
    Plugin Contributions
    0

    Default Re: Flag discontinued products

    Awesome!! This is good! It is working fine on 1.5.3. It seems like Discontinued image is placed with status image. I managed to create separate column for Discontinued on dataTableHeadingContent but I cant put the discontinued image on separate column.
    Click image for larger version. 

Name:	status_discontinued.jpg 
Views:	108 
Size:	9.5 KB 
ID:	15603

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Is there an automated way to remove discontinued products via a feed?
    By floridaguy43 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 2 Jan 2015, 02:40 AM
  2. v151 Discontinued Products Handling
    By Rizla in forum General Questions
    Replies: 3
    Last Post: 17 Jul 2014, 09:05 AM
  3. Deleting discontinued products
    By thelatinbarbie in forum General Questions
    Replies: 5
    Last Post: 2 Jun 2008, 11:12 PM
  4. Show a Discontinued Flag
    By Gyphon in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 29 May 2007, 06:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR