Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product listing sort order


spooks

Recommended Posts

Link to comment
Share on other sites

  • Replies 177
  • Created
  • Last Reply

Spooks, you are the Best

 

I did install the Ultimate SEO URLs contrib a while back. When I turn that off, my sort order problem goes away!!! Thanks so much for your help in pointing that out to me. I have not found the fix yet, but I see there are several versions after the one I installed, so it may be in one the new ones or in the thread somewhere. I guess will have to go find it.

 

Thanks again

Link to comment
Share on other sites

  • 3 months later...

I used Easy Populate to restore products back to osCommerce, but I want the latest models to show first. But there was a couple issues that made it difficult to achieve using the latest-first modification mentioned in the first page:

  • Since all of the products were restored from backup, all of the product's date added are exactly the same. So they sorted by the names.
  • The names, or rather, there are no names. We just copy the model number in the name field, and they go A-01, A-02, etc. With the higher numbers obviously being the latest.

So I did this:

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
			  $HTTP_GET_VARS['sort'] = 0 . 'd';
			  $listing_sql .=  " order by p.products_date_added DESC, p.products_model";
    } else {

But it doesn't take care of the latest model issue. How do I sort by date and models?

Link to comment
Share on other sites

all of the product's date added are exactly the same

 

It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way.

 

I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

It sounds like you have no data in your database related to the ordering you want, so its impossible to re-order that way.

 

I would look at modifying Easy Populate so it uses the original content for 'date added' instead of altering it, have you looked at the Easy Populate thread on this?

Well, it maybe my fault that I did not keep the original data, but that does not solve the issue. I use EP to add multiple products at once, and that's another scenario with the same issue.

 

As a solution, I want to sort first with date, then with models. How can I do that?

Link to comment
Share on other sites

Sorry, I `m not clear, does not your order by p.products_date_added DESC, p.products_model sort by model, your issue being all the dates are the same.

 

PS If you has auto backup installed (see signature) you could have gone back easily.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Well, I don't understand it myself. Is it sorting by models ascending or descending? Currently, the list goes A-01, A-02, and so on. If I add A-04 to A-10, I want it to go A-10, A-09, A-08 and so on till A-01.

Link to comment
Share on other sites

So are your saying you want is sorted ascending for alphabetical values, but descending for any subsequent numerical?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Could you check you're using the query you think you are by adding at the bottom of product_listing.php just before the final ?>

 

 echo '<hr>' . $listing_sql . '<hr>';

 

 

and saying what is shows.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Sorry for the late response (was already night the last I replied). So I did this to product_listing.php:

  <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
   </div>
echo '<hr>' . $listing_sql . '<hr>';
<?php
 }
?>
 </div>

I included a few lines of code before and after the line you told me to add to give you an idea.

 

Anyway, I don't think it worked as expected since this was the result:

echo '

' . $listing_sql . '

';

Link to comment
Share on other sites

@@oxwivi

 

That line is php, so must go inside the php tags, not outside, which is why I said just before the last ?> which is a php closing tag

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Oops, got confused by the question mark of the <?php there. So this time:

<?php
 }
 echo '<hr>' . $listing_sql . '<hr>';
?>

 

And the result:

select p.products_image, p.products_model, 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 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 = '4' order by p.products_date_added DESC, p.products_model
Link to comment
Share on other sites

Sorry, did'nt spot for looking before, i think the query your wanting is:

 

order by p.products_date_added DESC, p.products_model DESC

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Exactly :)

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

I read all this topic and other just like it and I still didn't find the answer to my problem, I hope someone can help me.

 

On osCommerce 2.2 I need to display the products in the following order: first, in alphabetical order, all the products that have stock quantity more than zero, and then, in alphabetical order, all the product with stock zero.

 

Can anyone help me with the code that I need to insert in the php files?

 

Thanks!

 

PS: I need to mention that I have a private work done on my site and a sort of a watermark automatically appears when a product's stock reaches zero. When I change that quantity to a value higher then zero the watermark automatically disappears. I just need all the products with zero stock to be listed last in the respective type of view (category view, manufacturer view, new products view, specials view, x-sales view)

Link to comment
Share on other sites

You would need to modify index.php to present your first query result to the product_listing.php module (as it does currently) then create a second and represent, it may need a number of alterations due to all the filter options on that page.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 4 weeks later...

order by p.products_date_added DESC, p.products_model DESC

 

I'm getting back to you about it late, very late, but there's an issue. On the first pages of any category, everything works fine, But going to the subsequent pages would show this top of the list:

Deprecated: Function ereg() is deprecated in /home/hijabi6/public_html/index.php on line159
Link to comment
Share on other sites

I'm getting back to you about it late, very late, but there's an issue. On the first pages of any category, everything works fine, But going to the subsequent pages would show this top of the list:

 

The fix for just this

http://www.oscommerce.com/community/contributions,7394

or migrate to 2.3.1 and fix this and other issues along the way ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

or migrate to 2.3.1 and fix this and other issues along the way ...

 

I'm already using osC 2.3.1. I think this issue appeared after using sorting code recommended in this thread. You can check the last two pages for the code I was told to use, if interested.

Link to comment
Share on other sites

I'm not an ereg / preg expert, I just know it was fixed in 2.3.1, if you find line 159 in index.php on your site, i would expect it to become clearer.

in the source of 2.3.1. you have lots of replacements, so i'd expect you'd find some example of how to change things.

 

here is some thread from the forum that might be helpful

http://www.oscommerce.com/forums/topic/341737-function-ereg-replace-is-deprecated/

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Well, the changed sort order indeed used ereg:

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
			 $HTTP_GET_VARS['sort'] = 0 . 'd';
			 $listing_sql .=  " order by p.products_date_added DESC, pd.products_name DESC";

 

However, changing it to !preg and going to next pages (as I described the issue first) does not load the list or the boxes and shows this error:

Fatal error: Call to undefined function preg() in /home/hijabi6/public_html/index.php on line159
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...