Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort Products By Dropdown


Recommended Posts

Morning,

 

I finally installed Sort Products by Dropdown.

The installation was quite easy, however I am having problems with the crontab.

 

I have set the Crontab in plesk (using plesk 8.1.0)

 

HTTP Server: Apache/2.0.55 (Ubuntu) mod_python/3.1.4 Python/2.4.3 PHP/4.4.2-1build1 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.7

PHP Version: 4.4.2-1build1 (Zend: 1.3.0)

 

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 1: ?php: No such file or directory

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 2: /bin: is a directory

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 5: osCommerce,: command not found

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 6: http://www.oscommerce.com: No such file or directory

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 8: 2006-06-10: command not found

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 10: Released: command not found

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 11: anon_ftp/: is a directory

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 13: syntax error near unexpected token `'includes/application_top.php''

/var/www/vhosts/domain.com.au/httpdocs/cron_update_bestsellers.php: line 13: ` require('includes/application_top.php');'

 

This is my first time using crontab.

 

Thanks in advance!

Laurence

Link to comment
Share on other sites

  • 5 weeks later...
  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

Hi all,

 

I have installed this contribution but confused about the sorting. I have tried to set the drop-down values to the column numbers in my "Product Listing" settings put sortring by price always fails. Also, If I use the exact value for the "Product Name" it also goes wrong. Let me show you what I mean.

 

Here are the setting from my Configutation:

 

Product Recent Sales 4

Display Product Image 1

Display Product Manufaturer Name 1

Display Product Model 0

Display Product Name 1

Display Product Price 2

Display Product Quantity 0

Display Product Weight 0

Display Buy Now column 3

Display Category/Manufacturer Filter (0=disable; 1=enable) 1

Location of Prev/Next Navigation Bar (1-top, 2-bottom, 3-both) 3

 

So by following the documentation I should set the dropdown values as follows:

 

$sort_list = array('4d' => 'Best Sellers',

'1a' => 'Products Name A to Z',

'1d' => 'Products Name Z to A',

'2a' => 'Price Low to High',

'2d' => 'Price High to Low');

 

If I do this, nothing sorts correctly. However:

 

$sort_list = array('4d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

 

Sorts the product A-Z and Z-A correctly, but the pricing never sorts...

 

To see this in action please click here. Try changing the sort order from the drop down.

 

This is one of the very last things I need to do before launchng this site so any help would be appreciated...

 

Cheers,

 

Roy

Link to comment
Share on other sites

$sort_list = array('4d' => 'Best Sellers',

'1a' => 'Products Name A to Z',

'1d' => 'Products Name Z to A',

'2a' => 'Price Low to High',

'2d' => 'Price High to Low');

 

If I do this, nothing sorts correctly. However:

 

$sort_list = array('4d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

 

All,

 

Now sorted it myself by playing with the values in the array... This is the combination that worked for me.

 

$sort_list = array('3d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'4a' => 'Price Low to High',

'4d' => 'Price High to Low');

 

Cheers,

 

Roy

Link to comment
Share on other sites

  • 2 weeks later...

My DESC sorts do not work, My A sorts work fine ?

 

What am I missing...

 

I have made all the changes to the 'index.php' and 'product_listing.php' file.

 

I have inclosed a pictuer of my osCommerce settings and the code listed below also to match setting. When I make the selection change to change the sort the parameters are changing on the address line.

 

Any help would be appreciated...

 

sortSettings.jpg

 

		 $sort_list = array('5d' => 'Best Sellers',
		  '2a' => 'Products Name A to Z',
						'2d' => 'Products Name Z to A',
						'0a' => 'Price Low to High',
						'0d' => 'Price High to Low');

Edited by sandwick
Link to comment
Share on other sites

  • 2 weeks later...
Hello,

 

First, thx for this contribution...

I've installed it but I've a little problem.

When I am logged in and I click on the dropdown to sort the products, I lose the session.

How to keep osCsid=.... ?

Someone can help me ?

Thank you

 

I'm having the same exact problem. I'm losing the session ID, which is deleting products that were in the shopping cart.

 

Help!

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys, Instuctions state to add::::

 

// Additional Products Sort

echo '<td align="center" class="dynamicMain">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>  ';

 

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('cPath', $cPath);

}

 

$sort_list = array('5d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

$sort_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');

echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));

echo '</form></td>' . "\n";

// End Additional Products Sort

 

 

 

BELOW:::

 

 

echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);

while ($filterlist = tep_db_fetch_array($filterlist_query)) {

$options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);

}

echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');

echo '</form></td>' . "\n";

}

 

 

ONE PROBLEM! I do not have

 

 

echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);

while ($filterlist = tep_db_fetch_array($filterlist_query)) {

$options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);

}

echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');

echo '</form></td>' . "\n";

}

 

In my index page

 

My dropmenu shows up. gooks good.

It refreshes page when made a selection,

 

Best Sellers

Products Name A to Z

Products Name Z to A

Price Low to High

Price High to Low

 

No errors

But, all it doese is refresh the page, no search results.

 

Can someone give he a hint on what went wrong?

 

Thanks,

Ronnie

Link to comment
Share on other sites

Does anybody know a way to set this amazing contribution, in a way we can use simple links instead of a dropdown?

 

Something similar to a line with links like "Sort by bigger price" or something like "Price:" and then 2 images one with an up arrow and other with a down arrow. and when the costumer click it will do the sort...

 

I don't know if I exlained myself well but does anybody know how to do this?

 

Thanks in advance

Link to comment
Share on other sites

I have still not found a resolution for my problem. Anytime I use the dropdown menu to sort products, it drops the session id and deletes everything from the shopping cart. This is obviously not good.

 

Try it out here: http://kimandjason.com/shop/home-office-be...251_77_169.html (Be sure to add something to the cart first, then try the dropdown menu.)

 

I'm surprised other people are not having the same problem.

 

If I can't get this to work, I'll have to remove this contribution, which would stink because I love it!

 

Somebody -- PLEASE HELP!

Link to comment
Share on other sites

  • 1 month later...
Hi,

 

I've installed this and all seems well until I try to click on the next page (or any other page numbered) within the results, without resorting from the drop down menu.

 

I get the following error message come up and I have seen that others also receive the same message but havent seen a solution to resolve it. Message reads:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p.products_recent_sales desc, pd.products_name desc' at line 1

 

select count(p.products_id) as total from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, 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 = '1' and p2c.categories_id = '14'p.products_recent_sales desc, pd.products_name desc

 

[TEP STOP]

 

 

 

If I sort the products with the dropdown menu and try changing the page it all works great. Any suggestions?

 

Thanks in advance.

 

 

Sorry, I've managed to sort it myself, just incase others get the same problem, this is what I did.

 

On the Installation instructions it states to have the following:

 

 

 

And to rectify it I added Order by so the 2 lines in question now looked like this:

 

 

 

Hope this helps if you encounter the same problem.

I had the same error message after installation. I deleted the "order by" before "pd.products_name" and "p.products_recent_sales desc" and it worked. But I had a problem running the Cron job. The confirmation email I receive says:

Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.

 

But my register_globals are set on in php.ini file. I have other contribution which requires register_global to be on working as well. So can someone help me with this dilemma? Otherwise, the contribution can't really tell buyers which items are best sellers.

Link to comment
Share on other sites

  • 1 month later...

Hi

 

I have installed this contribution it is exactly what i am looking for. But i have one problem my Best Sellers seems to show as "products z to a" instead. I cant figure out what i did wrong, no sure if i have my cron jobs set up right.

 

Can anyone help!!!

 

Thanks

 

ClaireB

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 months later...

I have installed this module but it's acting a bit weird with sorting the results out.

 

I've been going at this for a few hours and having a break for a while. I find coming back fresh that you can resolve problems quickly sometimes.

 

If anyone has any ideas or suggestions, I'd really appreciate it!

 

Cheers,

Nigel

 

Here's the shop address -

 

http://64.176.202.17/catalog/index.php?cPa...&filter_id=

Link to comment
Share on other sites

  • 1 month later...

Thanks for this helpful CONTRI,

 

I found here a little bug in this:

 

when i set Admin->Productlisting->display product model value to 2 or 3 or 4 or 5 ,

 

the sort_products_by_dropdown don't works.

 

 

I think u can modify it .

 

 

thanks

 

 

 

JUN

Link to comment
Share on other sites

  • 2 weeks later...
Support forum for Sort Products By Dropdown

 

WHAT THIS CONTRIB DOES:

This contribution allows you to sort the products in a category by multiple methods, by best sellers, products name, and by price. The best sellers are updated daily by cron job and you can set the number of days back to look at sales to base your best sellers on.

 

The way sort by price and name is pretty straightforward, the way best sellers works is each order counts as one sale so if someone orders 50 of item (A) and item ( B ) is ordered 5 times but only 1 each time, item ( B ) will show 5 sales and item (A) will show only 1 so the one that was more popular with multiple people will be ranked higher -- item B. This can be changed by modifying the code in cron_update_bestsellers.php slightly if you wish to count by total number of items sold instead it is noted how to do so in the code.

 

 

This contribution is exactly what i'm looking for, thanks for building it.

But... I can't get it to work.

I've setup version 1.2 everything exactly as per the instructions but the drop down box doesn't show up anywhere.

I do have the "Display Categories/Manufacturers Filter" set to 1.

But still no dropdown box anywhere.

Where should i see it anyways?

 

Any help would be greatly appreciated.

 

Thank you.

Link to comment
Share on other sites

  • 1 month later...

hello :)

 

I really like the look of this contribution.

 

I have a small well probably big problem, My oscommerce is using a template i purchased from templatemonster.com so the laout etc is very different. I was wondering if the makers of this addon would be intersted in installing this addon for me, I am pretty sure it will need some custom coding done. Obviously I will pay. My site is http://www.nawtytoys.co.uk/Shop I have tried to install it myself but it screws up the layout and also it doesnt sort the products correctly.

 

So PLEASE can you contact me if you can do this.

 

Regards

Donny

Link to comment
Share on other sites

  • 2 months later...

I had a problem running the Cron job. The confirmation email I receive says:

Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.

 

But my register_globals are set on in php.ini file. I have other contribution which requires register_global to be on working as well. So can someone help me with this dilemma? Otherwise, the contribution can't really tell buyers which items are best sellers.

 

This was posted a year ago and I'm wondering if you ever got it fixed. This is what my hosts tech guys had to say:

 

"It appears that the script you are calling (cron_update_bestsellers.php) is querying the systems default php settings rather than the php.ini within the same account/directory.

 

I was able to run this by altering the system default for your VPS, however depending on the nature of any of your other scripts, this may cause them to behave in a manner not intended. Ideally, the script should be reading from the php.ini or the .htaccess file located in the same location, however I was not able to coax it to do so."

 

So now I know what the problem is, but I have no idea how to fix it. This year-old post is the only one I could find on this topic.

 

Thanks,

Adrienne

Link to comment
Share on other sites

  • 3 months later...

I need help with this contribution. Works fine but...

 

Im using other contribution (Better Product Display and Listing). That contribution dont use colums. The conjob with the Best sellers works but when I filter products AZ or Price-+ nothing happens.

 

This is may code:

// sort order by drop down menu
//    if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
   if ( (!isset($HTTP_GET_VARS['sortdir'])) || (!isset($HTTP_GET_VARS['sortcol'])) || (!ereg('[1-8]', $HTTP_GET_VARS['sortcol'])) || (!ereg('[ad]', $HTTP_GET_VARS['sortdir'])) || ($HTTP_GET_VARS['sortcol'] > sizeof($column_list)) ) {
// sort order by drop down menu

     for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
       if ($column_list[$i] == 'PRODUCT_LIST_30SALES') {


// sort order by drop down menu
//          $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $HTTP_GET_VARS['sortcol'] = $i+1;
         $HTTP_GET_VARS['sortdir'] = 'a';
// sort order by drop down menu

         $listing_sql .= " order by p.products_recent_sales desc, pd.products_name desc";
         break;
       }
     }
   } else {

// sort order by drop down menu
//      $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
//      $sort_order = substr($HTTP_GET_VARS['sort'], 1);
     $sort_col = $HTTP_GET_VARS['sortcol'];
     $sort_order = $HTTP_GET_VARS['sortdir'];
// sort order by drop down menu	


     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_30SALES':
//         $listing_sql .= "order by p.products_recent_sales desc, pd.products_name desc";
//         break;
//         case 'PRODUCT_LIST_30SALES':
//          $listing_sql .= " order by p.products_recent_sales, pd.products_name desc " . ($sort_order == 'd' ? 'desc' : '');
//         break;
       case 'PRODUCT_LIST_30SALES':
         $listing_sql .= " order by p.products_recent_sales " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name desc";
         break;

Link to comment
Share on other sites

In this part are the forms:

            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>        
<?php
// optional Product List Filter
   if (PRODUCT_LIST_FILTER < 100) {
     if (isset($HTTP_GET_VARS['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" . $new_products_where . " and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['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 . "'" . $new_products_where . " order by m.manufacturers_name";
     }
     $filterlist_query = tep_db_query($filterlist_sql);
     if (tep_db_num_rows($filterlist_query) < 100) {
       echo '            <td align="right">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
       } else {
         echo tep_draw_hidden_field('cPath', $cPath);
         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
       }


// sort order by drop down menu
//      echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
      echo tep_draw_hidden_field('sortcol', $HTTP_GET_VARS['sortcol']);
        echo tep_draw_hidden_field('sortdir', $HTTP_GET_VARS['sortdir']);
// sort order by drop down menu	

       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo tep_hide_session_id() . '</form></td>' . "\n";
     }


   // Additional Products Sort
     echo '<td align="center" class="dynamicMain">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>  ';


     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
     } else {
         echo tep_draw_hidden_field('cPath', $cPath);
     }

     $sort_list = array('12d' => 'Best Sellers',
     			'4a' => 'Products Name A to Z',
                        '4d' => 'Products Name Z to A',
                        '5a' => 'Price Low to High',
                        '5d' => 'Price High to Low');
     foreach($sort_list as $id=>$text) {
      $sort_range[] = array('id' => $id, 'text' => $text);
     }

     echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');
     echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));
     echo '</form></td>' . "\n";
    // End Additional Products Sort


// Get the right image for the top-right
   $image = DIR_WS_IMAGES . 'table_background_list.gif';
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['manufacturers_image'];
   } elseif ($current_category_id) {
     $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['categories_image'];
   }

Link to comment
Share on other sites

Get working!

 

added to includes/languages/*/index.php

  define('TEXT_FILTER_ALL', 'Todos');
 define('TEXT_FILTER_FROM', 'Desde');
 define('TEXT_FILTER_TO', 'hasta 50€');
 define('TEXT_FILTER_BY', 'ORDENAR');
 define('TEXT_FILTER_AZ', 'AZ- ascendente por Nombre.');
 define('TEXT_FILTER_ZA', 'ZA - descendente por Nombre.');
 define('TEXT_FILTER_MINORPRICE', '< - de menor a mayor Precio.');
 define('TEXT_FILTER_MAYORPRICE', '> - de mayor a menor Precio.');
 define('TEXT_FILTER_BEST', 'los más vendidos.');
 define('TEXT_SHOW', 'FILTRAR:');
 define('TEXT_SHOW2', 'PRECIO:>');

 

index.php

    $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_30SALES':
         $select_column_list .= 'p.products_recent_sales, ';
         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;
       case 'PRODUCT_LIST_AVAILABLE':
         $select_column_list .= 'p.products_date_available, ';
         break;
     }
   }

// Unless Customer logged in show products
 if (!tep_session_is_registered('customer_id')) {
   $new_products_where=" and p2c.categories_id <> '$restricted_category' ";
 } else {
   $new_products_where='';
 }

// 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
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, 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'] . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, 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 pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " 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
// p.products_date_added to query for New Product Icon contribution
     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_date_added, p.products_id, p.products_recent_sales, 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 . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, 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 . "'" . $new_products_where . "";
     }
   }


// sort order by drop down menu
   if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
//    if ( (!isset($HTTP_GET_VARS['sortdir'])) || (!isset($HTTP_GET_VARS['sortcol'])) || (!ereg('[1-8]', $HTTP_GET_VARS['sortcol'])) || (!ereg('[ad]', $HTTP_GET_VARS['sortdir'])) || ($HTTP_GET_VARS['sortcol'] > sizeof($column_list)) ) {
// sort order by drop down menu

     for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
//    if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
      if ($column_list[$i] == 'PRODUCT_LIST_30SALES') {


// sort order by drop down menu
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
//          $HTTP_GET_VARS['sortcol'] = $i+1;
         $HTTP_GET_VARS['sortdir'] = 'a';
// sort order by drop down menu


//       $listing_sql .= " order by pd.products_name";
        $listing_sql .= " order by p.products_recent_sales desc, pd.products_name desc";
         break;
       }
     }
   } else {

// sort order by drop down menu
     $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
     $sort_order = substr($HTTP_GET_VARS['sort'], 1);
//     $sort_col = $HTTP_GET_VARS['sortcol'];
//      $sort_order = $HTTP_GET_VARS['sortdir'];
// sort order by drop down menu	


     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_30SALES':
         $listing_sql .= "order by p.products_recent_sales desc, pd.products_name desc";
          break;

//       case 'PRODUCT_LIST_30SALES':
//        $listing_sql .= " order by p.products_recent_sales, pd.products_name desc " . ($sort_order == 'd' ? 'desc' : '');
//       break;

//        case 'PRODUCT_LIST_30SALES':
//         $listing_sql .= " order by p.products_recent_sales " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name 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_AVAILABLE':
         $listing_sql .= "p.products_date_available " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; 
         break;
       case 'PRODUCT_LIST_PRICE':
         $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_PRICE_EX':
         $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
     }
   }
?>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr >
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>


   <?php        

// optional Product List Filter
   if (PRODUCT_LIST_FILTER < 100) {
     if (isset($HTTP_GET_VARS['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" . $new_products_where . " and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['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 . "'" . $new_products_where . " order by m.manufacturers_name";
     }
     $filterlist_query = tep_db_query($filterlist_sql);
     if (tep_db_num_rows($filterlist_query) < 100) {
       echo '

<td align="right" class="blue">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
       } else {
         echo tep_draw_hidden_field('cPath', $cPath);
         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
       }

// sort order by drop down menu
     echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
//       echo tep_draw_hidden_field('sortcol', $HTTP_GET_VARS['sortcol']);
        echo tep_draw_hidden_field('sortdir', $HTTP_GET_VARS['sortdir']);
// sort order by drop down menu	

       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }

       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo tep_hide_session_id() . ' </form> </td>' . "\n";
     }

   // Additional Products Sort
     echo '

<td align="center" class="blue">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . TEXT_FILTER_BY . ' ';
     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
     } else {
         echo tep_draw_hidden_field('cPath', $cPath);
     }

     $sort_list = array(
                             '12d' => TEXT_FILTER_BEST,
//	     			      '4a' => TEXT_FILTER_AZ,
     			      '4a' => TEXT_FILTER_AZ,
                        '4d' => TEXT_FILTER_ZA,
                        '5a' => TEXT_FILTER_MINORPRICE,
                             '5d' => TEXT_FILTER_MAYORPRICE
//                             '12d' => TEXT_FILTER_BEST ''
                             );

     foreach($sort_list as $id=>$text) {
      $sort_range[] = array('id' => $id, 'text' => $text);
     }

     echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');
     echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));


     echo tep_hide_session_id() . '</form></td>' . "\n";
    // End Additional Products Sort     

// Get the right image for the top-right
   $image = DIR_WS_IMAGES . 'table_background_list.gif';
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['manufacturers_image'];
   } elseif ($current_category_id) {
     $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['categories_image'];
   }
     // -------------- SORT BY PRICE -------------- //

$filterlist_sql= "select distinct p.products_price as id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by p.products_price";

$categorie = $current_category_id;
$filterlist_query = tep_db_query($filterlist_sql);


if (tep_db_num_rows($filterlist_query) > 1)
{
echo '            

<td align="left" class="blue">' . tep_draw_form('filter', 'advanced_search_result.php', 'get') . TEXT_SHOW2 . ' ';

echo tep_draw_hidden_field('categories_id', $categorie);
$options = array(array('id' => '', 'text' => TEXT_FILTER_ALL ));

Link to comment
Share on other sites

  • 2 months later...

I would like to use this but not with best sellers - only price sort high to low and low to high and product name, a - z and z- a. Can this be done and what changes to the install do I need to do.

 

Here's hoping someone can help!

 

Sue

Design by Sue

Link to comment
Share on other sites

I actually got it!! for anyone else who wants this you simply add the following code (to index.php)

 

 

 

 // Additional Products Sort
     echo '<td align="center" class="dynamicMain">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>  ';


     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
     } else {
         echo tep_draw_hidden_field('cPath', $cPath);
     }

     $sort_list = array('1a' => 'Products Name A to Z',
                        '1d' => 'Products Name Z to A',
                        '5a' => 'Price Low to High',
                        '5d' => 'Price High to Low');
     foreach($sort_list as $id=>$text) {
      $sort_range[] = array('id' => $id, 'text' => $text);
     }

     echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');
     echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));
     echo '</form></td>' . "\n";
// End Additional Products Sort

 

 

after

 

        echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo '</form></td>' . "\n";
     }

 

and before

    }

 

Be sure to follow the directions from the add on here link to be sure your name and price number are correct. (All I did was remove the best sellers from the drop down and used only this code on the index.php as it appears that all of the other code for the add on had to do with the info needed for the best sellers sort)

 

Sue

Link to comment
Share on other sites

  • 3 months later...

Hi everyone.

 

I have a little issue, that I do not know if its only me that has it.

 

If I'm in a category and I select to filter products for certain manufacturer and then use the dropdown box to sort the listing, no matter what option I click, it never works.

 

If only works if I do not have a manufacter selected.

 

Ive checked in Admin the visible columns and there numbers and they all are the same has the ones in Index.php

 

$sort_list = array('10d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

 

I also have the manufacter column visible, its number 6.

 

One more thing... If I use oscommerce default sort option, with a manufacter selected, and then sort list by price, again using oscommerce default heading sort option, it works, and the dropdown box with the sort option will hold the correct option. Weird ah? seems it will not work if I click on it.

 

Can you please help me?

 

Thanks.

Link to comment
Share on other sites

Hi everyone.

 

I have a little issue, that I do not know if its only me that has it.

 

If I'm in a category and I select to filter products for certain manufacturer and then use the dropdown box to sort the listing, no matter what option I click, it never works.

 

If only works if I do not have a manufacter selected.

 

Ive checked in Admin the visible columns and there numbers and they all are the same has the ones in Index.php

 

$sort_list = array('10d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

 

I also have the manufacter column visible, its number 6.

 

One more thing... If I use oscommerce default sort option, with a manufacter selected, and then sort list by price, again using oscommerce default heading sort option, it works, and the dropdown box with the sort option will hold the correct option. Weird ah? seems it will not work if I click on it.

 

Can you please help me?

 

Thanks.

 

Hi,

I figured out the problem and fixed it.

 

I also have Ultimate SEO URLs contribution.

In the URLs it was adding a "&" instead of only "&" and that was causing the listing to get confused because it could not read the parameters.

So I fixed the issue with the URL that was caused by the other contribution and all works fine now.

 

In case you bump in to the same issue now you now!! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...