Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    319
    Plugin Contributions
    0

    Default modified product filter / alpha filter help please

    Hi,
    i have modified the alpha filter using product_filter_module_for_zencart_1-0 then i have modified it slightly myself. i want to filter products by product model only showing items with model beginning stock-

    http://www.onyourbike.co.uk/clearanc...rthern-ireland

    this lets people see items that i have on display instore

    i have it working fine except when in category listings

    http://www.onyourbike.co.uk/bikes/20-bmx-bikes

    when you search for item then select filter to only show items instore it shows no products

    http://www.onyourbike.co.uk/search-r...rigger&x=0&y=0

    here is the code i have in default_filter.php

    PHP Code:
    <?php
    /**
     * default_filter.php  for index filters
     *
     * index filter for the default product type
     * show the products of a specified manufacturer
     *
     * @package productTypes
     * @copyright Copyright 2003-2009 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @todo Need to add/fine-tune ability to override or insert entry-points on a per-product-type basis
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: default_filter.php 14870 2009-11-19 22:36:24Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
      if (isset(
    $_GET['alpha_filter_id']) && (int)$_GET['alpha_filter_id'] > 0) {
        
    //$alpha_sort = " and pd.products_name LIKE '" . chr((int)$_GET['alpha_filter_id']) . "%' ";
        
    $filterid = (int)$_GET['alpha_filter_id'];
        switch(
    $filterid)
        {
                case 
    7:
                    
    $STOCK_LIMIT_CODE 'STOCK-%';
                    break;
                        }
      } else {
        
    $alpha_sort '';
        
    $STOCK_LIMIT_CODE '%';
      }
      if (!isset(
    $select_column_list)) $select_column_list "";
       
    // show the products of a specified manufacturer
      
    if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '' ) {
        if (isset(
    $_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
    // We are asked to show only a specific category
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_model, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = 1, s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
           from " 
    TABLE_PRODUCTS " p left join " TABLE_SPECIALS " s on p.products_id = s.products_id , " .
           
    TABLE_PRODUCTS_DESCRIPTION " pd, " .
           
    TABLE_MANUFACTURERS " m, " .
           
    TABLE_PRODUCTS_TO_CATEGORIES " p2c
           where p.products_status = 1
           and p.products_model LIKE '" 
    $STOCK_LIMIT_CODE "'
             and p.manufacturers_id = m.manufacturers_id
             and m.manufacturers_id = '" 
    . (int)$_GET['manufacturers_id'] . "'
             and p.products_id = p2c.products_id
             and pd.products_id = p2c.products_id
             and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
             and p2c.categories_id = '" 
    . (int)$_GET['filter_id'] . "'" .
             
    $alpha_sort;
        } else {
    // We show them all
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_model, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
          from " 
    TABLE_PRODUCTS " p left join " TABLE_SPECIALS " s on p.products_id = s.products_id, " .
          
    TABLE_PRODUCTS_DESCRIPTION " pd, " .
          
    TABLE_MANUFACTURERS " m
          where p.products_status = 1
          and p.products_model LIKE '" 
    $STOCK_LIMIT_CODE "'
            and pd.products_id = p.products_id
            and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
            and p.manufacturers_id = m.manufacturers_id
            and m.manufacturers_id = '" 
    . (int)$_GET['manufacturers_id'] . "'" .
            
    $alpha_sort;
        }
      } else {
    // show the products in a given category
        
    if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
    // We are asked to show only specific category
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_model, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
          from " 
    TABLE_PRODUCTS " p left join " TABLE_SPECIALS " s on p.products_id = s.products_id, " .
          
    TABLE_PRODUCTS_DESCRIPTION " pd, " .
          
    TABLE_MANUFACTURERS " m, " .
          
    TABLE_PRODUCTS_TO_CATEGORIES " p2c
          where p.products_status = 1
          and p.products_model LIKE '" 
    $STOCK_LIMIT_CODE "'
            and p.manufacturers_id = m.manufacturers_id
            and m.manufacturers_id = '" 
    . (int)$_GET['filter_id'] . "'
            and p.products_id = p2c.products_id
            and pd.products_id = p2c.products_id
            and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
            and p2c.categories_id = '" 
    . (int)$current_category_id "'" .
            
    $alpha_sort;
        } else {
    // We show them all
          
    $listing_sql "select " $select_column_list " p.products_id, p.products_model, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
           from " 
    TABLE_PRODUCTS_DESCRIPTION " pd, " .
           
    TABLE_PRODUCTS " p left join " TABLE_MANUFACTURERS " m on p.manufacturers_id = m.manufacturers_id, " .
           
    TABLE_PRODUCTS_TO_CATEGORIES " p2c left join " TABLE_SPECIALS " s on p2c.products_id = s.products_id
           where p.products_status = 1
             and p.products_model LIKE '" 
    $STOCK_LIMIT_CODE "'
             and p.products_id = p2c.products_id
             and pd.products_id = p2c.products_id
             and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
             and p2c.categories_id = '" 
    . (int)$current_category_id "'" .
             
    $alpha_sort;
        }
      }

    // set the default sort order setting from the Admin when not defined by customer
      
    if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
        
    $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
      }

      if (isset(
    $column_list)) {
        if ((!isset(
    $_GET['sort'])) || (isset($_GET['sort']) && !preg_match('/[1-8][ad]/'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($column_list)) ) {
          for (
    $i=0$n=sizeof($column_list); $i<$n$i++) {
            if (isset(
    $column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
              
    $_GET['sort'] = $i+'a';
              
    $listing_sql .= " order by p.products_sort_order, pd.products_name";
              break;
            } else {
    // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank
    // for reverse, descending order use:
    //       $listing_sql .= " order by p.products_sort_order desc, pd.products_name";
              
    $listing_sql .= " order by p.products_sort_order, pd.products_name";
              break;
            }
          }
    // if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
          
    if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
            
    $_GET['sort'] = '20a';
          }
        } else {
          
    $sort_col substr($_GET['sort'], 1);
          
    $sort_order substr($_GET['sort'], 1);
          switch (
    $column_list[$sort_col-1]) {
            case 
    'PRODUCT_LIST_MODEL':
              
    $listing_sql .= " order by p.products_model " . ($sort_order == 'd' 'desc' '') . ", pd.products_name";
              break;
            case 
    'PRODUCT_LIST_NAME':
              
    $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' 'desc' '');
              break;
            case 
    'PRODUCT_LIST_MANUFACTURER':
              
    $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' 'desc' '') . ", pd.products_name";
              break;
            case 
    'PRODUCT_LIST_QUANTITY':
              
    $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' 'desc' '') . ", pd.products_name";
              break;
            case 
    'PRODUCT_LIST_IMAGE':
              
    $listing_sql .= " order by pd.products_name";
              break;
            case 
    'PRODUCT_LIST_WEIGHT':
              
    $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' 'desc' '') . ", pd.products_name";
              break;
            case 
    'PRODUCT_LIST_PRICE':
              
    $listing_sql .= " order by p.products_price_sorter " . ($sort_order == 'd' 'desc' '') . ", pd.products_name";
              break;
          }
        }
      }
    // optional Product List Filter
      
    if (PRODUCT_LIST_FILTER 0) {
        if (isset(
    $_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '') {
          
    $filterlist_sql "select distinct c.categories_id as id, cd.categories_name as name
          from " 
    TABLE_PRODUCTS " p, " .
          
    TABLE_PRODUCTS_TO_CATEGORIES " p2c, " .
          
    TABLE_CATEGORIES " c, " .
          
    TABLE_CATEGORIES_DESCRIPTION " cd
          where p.products_status = 1
            and p.products_id = p2c.products_id
            and p2c.categories_id = c.categories_id
            and p2c.categories_id = cd.categories_id
            and cd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
            and p.manufacturers_id = '" 
    . (int)$_GET['manufacturers_id'] . "'
          order by cd.categories_name"
    ;
        } else {
          
    $filterlist_sql"select distinct m.manufacturers_id as id, m.manufacturers_name as name
          from " 
    TABLE_PRODUCTS " p, " .
          
    TABLE_PRODUCTS_TO_CATEGORIES " p2c, " .
          
    TABLE_MANUFACTURERS " m
          where p.products_status = 1
            and p.manufacturers_id = m.manufacturers_id
            and p.products_id = p2c.products_id
            and p2c.categories_id = '" 
    . (int)$current_category_id "'
          order by m.manufacturers_name"
    ;
        }
        
    $do_filter_list false;
        
    $filterlist $db->Execute($filterlist_sql);
        if (
    $filterlist->RecordCount() > 1) {
            
    $do_filter_list true;
          if (isset(
    $_GET['manufacturers_id'])) {
            
    $getoption_set =  true;
            
    $get_option_variable 'manufacturers_id';
            
    $options = array(array('id' => '''text' => TEXT_ALL_CATEGORIES));
          } else {
            
    $options = array(array('id' => '''text' => TEXT_ALL_MANUFACTURERS));
          }
          while (!
    $filterlist->EOF) {
            
    $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
            
    $filterlist->MoveNext();
          }
        }
      }
    i have changed a few lines filtering products_model by

    using p.products_model LIKE '" . $STOCK_LIMIT_CODE . "'

    but on search page this isnt working so do i need to add something in a different page, as you can see im no expert and any help appreciated, i hope i have explained myself properly / clearly

    thanks
    bryan
    Last edited by bn17311; 5 Oct 2011 at 06:24 PM. Reason: change

  2. #2
    Join Date
    Apr 2010
    Posts
    319
    Plugin Contributions
    0

    Default Re: modified product filter / alpha filter help please

    well got it to work eventually

    i can now filter advanced search using different product model for items kept instore or items available to order

    http://www.onyourbike.co.uk/search-r...ha_filter_id=0

    thanks to anyone for reading

    bryan

 

 

Similar Threads

  1. v154 Converting Alpha Filter to UL-List
    By rbarbour in forum General Questions
    Replies: 5
    Last Post: 9 Feb 2016, 10:11 AM
  2. v153 Alpha Filter
    By rbarbour in forum General Questions
    Replies: 3
    Last Post: 7 Oct 2014, 11:51 PM
  3. manufacturer & alpha filter
    By rbarbour in forum General Questions
    Replies: 7
    Last Post: 3 Jun 2012, 12:33 PM
  4. Add alpha filter for new product field
    By yakbuttertea in forum Basic Configuration
    Replies: 2
    Last Post: 26 Mar 2009, 07:34 PM
  5. Replacing Alpha Filter with Sort By
    By dhanesh in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 26 Nov 2008, 01:11 AM

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