Guest Posted May 9, 2011 Share Posted May 9, 2011 For some reason my products no longer sort themselves alphabetically. Now they are sorting based on when I added them. I cannot find the code to revert it back to sorting the products alphabetically. I would really like my products to sort alphabetically, can anyone please help? Thanks! Link to comment Share on other sites More sharing options...
KDM Posted May 9, 2011 Share Posted May 9, 2011 For some reason my products no longer sort themselves alphabetically. Now they are sorting based on when I added them. I cannot find the code to revert it back to sorting the products alphabetically. I would really like my products to sort alphabetically, can anyone please help? Thanks! Programs don't just stop doing it's function. Was any changes made to the queries if so you need to find out what and that needs to be changed back. The query is what displays your products on any given page. The initial page is the only page where products are listed by date added that I'm aware of. That page will always be that way unless some modifications are made and that would be through a new query. Link to comment Share on other sites More sharing options...
Guest Posted May 9, 2011 Share Posted May 9, 2011 Programs don't just stop doing it's function. Was any changes made to the queries if so you need to find out what and that needs to be changed back. The query is what displays your products on any given page. The initial page is the only page where products are listed by date added that I'm aware of. That page will always be that way unless some modifications are made and that would be through a new query. I had a developer work on it to customize the cart. They must have done something that made it work in a different manner but now I cannot reach them. Link to comment Share on other sites More sharing options...
KDM Posted May 9, 2011 Share Posted May 9, 2011 I had a developer work on it to customize the cart. They must have done something that made it work in a different manner but now I cannot reach them. The developer would of course know the changes made. That being said you could do a file compare with a program, comparing the original code files with those on your system now. Pay particular attention to the query changes as that should be the problem. If you have limited programming skills you may need another programmer/developer to take a look. Link to comment Share on other sites More sharing options...
satish Posted May 10, 2011 Share Posted May 10, 2011 which module(new, specials ). Or is it for all product listings. Satish Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site. Check My About US For who am I and what My company does. Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2011 Share Posted May 10, 2011 which module(new, specials ). Or is it for all product listings. Satish It's all the product listings. When I create new products, they appear in the system in the order I placed them and not alphabetically. I have limited programming knowledge, I'm more of a designer. I would compare the original code but I wouldn't know which files to look and the code all looks like something from the Matrix to me. If someone can point me to the file or files I need to inspect, I'll try to run a comparison. Thanks everyone, you've been a great help. Link to comment Share on other sites More sharing options...
KDM Posted May 10, 2011 Share Posted May 10, 2011 It's all the product listings. When I create new products, they appear in the system in the order I placed them and not alphabetically. I have limited programming knowledge, I'm more of a designer. I would compare the original code but I wouldn't know which files to look and the code all looks like something from the Matrix to me. If someone can point me to the file or files I need to inspect, I'll try to run a comparison. Thanks everyone, you've been a great help. The product listing when categories are chosen is done in; catalog/index.php several choices of order by are used depending upon what the customer chooses and the setting in admin - configuration - product listing side of your store: Check these starting with the product listing in your admin product listing the default settings are Display Product Image 1 Display Product Manufaturer Name 0 Display Product Model 0 Display Product Name 2 Display Product Price 3 Display Product Quantity 0 Display Product Weight 0 Display Buy Now column 4 Display Category/Manufacturer Filter (0=disable; 1=enable) 1 Location of Prev/Next Navigation Bar (1-top, 2-bottom, 3-both) 2 You can experiment with these before checking the code. You really don't want to mess with the code if you don't know what you are doing. If you want to play with the code always make a copy before you change anything as that will make it much easier to revert back to where you started as compared to trying to remember all the changes you made. Also any changes you do make you would want to put comments in your code for future reference. Comments are made two ways: each line of comments must be preceded by two forward slashes // this would be a comment in the code on one line comments surrounded by forward slash-star and star-forward slash /* this would be a comment in the code on one line or more as long as it is within these */ elseif ($category_depth == 'products' || isset($_GET['manufacturers_id'])) { // 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); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } // show the products of a specified manufacturer if (isset($_GET['manufacturers_id'])) { if (isset($_GET['filter_id']) && tep_not_null($_GET['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)$_GET['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)$_GET['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)$_GET['manufacturers_id'] . "'"; } } else { // show the products in a given categorie if (isset($_GET['filter_id']) && tep_not_null($_GET['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)$_GET['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 . "'"; } } if ( (!isset($_GET['sort'])) || (!ereg('^[1-8][ad]$', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $_GET['sort'] = $i+1 . 'a'; $listing_sql .= " order by pd.products_name"; break; } } } else { $sort_col = substr($_GET['sort'], 0 , 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 .= " [u][b]order by final_price[/b][/u] " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; } } When first entering the website the query in: catalog/includes/modules/new_products.php. is used. You have 2 queries. They are both ordered by date added. This is stock osCommerce. This can be changed to whatever order that you want, I use a random query so that different products will always show when entering my site. if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } Good luck Link to comment Share on other sites More sharing options...
satish Posted May 10, 2011 Share Posted May 10, 2011 As stated by KDM $listing_sql .= " order by pd.products_name"; this is required sql for order by. Satish Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site. Check My About US For who am I and what My company does. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.