Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

timint

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by timint

  1. A customer of mine wants a product filter with multi selecting manufacturers. But SEO URLs 5 does not support array HTTP GET parameters. Do anyone know a solution for this?

     

    index.php?manufacturers[]=1&manufacturers[]=2&manufacturers[]=3

     

    returns

     

    index.php?manufacturers=Array

     

    I know oscommerce also has this limitation but a one level depth array was easily fixed in tep_href_link, or if it was tep_get_all_get_parameters.

  2. Digg it or call me crazy...

     

    Examples from catalog/index.php

     

    // create column list
       $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                            'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                            'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                            'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                            'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                            'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                            'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                            'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

     

    Drop all the crazy whitespace and make it mod-friendly

     

    // create column list
       $define_list = array(
         'PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
         'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
         'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
         'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
       // BOF: Mod example
         'PRODUCT_LIST_FIELD' => PRODUCT_LIST_FIELD,
       // EOF: Mod example
         'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
         'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
         'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
         'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW,  // <--- coma ending
       );

     

    Why 4 sql queries?

     

    // show the products of a specified manufacturer
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
    // We are asked to show only a specific category
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price 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.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
         } else {
    // We show them all
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price 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 pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
         }
       } else {
    // show the products in a given categorie
         if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
    // We are asked to show only specific catgeory
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price 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.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
         } else {
    // We show them all
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
         }
       }

     

    Where one is enough

     

        $listing_sql = 
         "select distinct " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price
         from " . TABLE_PRODUCTS . " p
         left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on (p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "')
         left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id)
         left join " . TABLE_SPECIALS . " s on (p.products_id = s.products_id)
         left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on (p.products_id = p2c.products_id)
         where p.products_status = '1'
         ". ((isset($HTTP_GET_VARS['manufacturers_id'])) ? "and m.manufacturers_id = '" . tep_db_input($HTTP_GET_VARS['manufacturers_id']) . "'" : false) ."
         ". ((isset($HTTP_GET_VARS['filter_id'])) ? "and p2c.categories_id = '" . tep_db_input($HTTP_GET_VARS['filter_id']) . "'" : false) ."
         and p2c.categories_id = '" . (int)$current_category_id . "';

     

    Line breaking sql queries is also friendlier for the human eye.

×
×
  • Create New...