Page 1 of 1

[MOD] Latest Prod use date_available instead of date_added

Posted: Wed Jul 14, 2010 12:55 am
by Johnathan
I think it works a lot better for Latest Products to be based on date_available instead of date_added, since date_available can be changed in the admin. This way products can be created ahead of time and still appear on the correct date as a "latest product". It's an easy fix, too:

IN:

Code: Select all

/catalog/model/catalog/product.php
REPLACE:

Code: Select all

ORDER BY p.date_added
WITH:

Code: Select all

ORDER BY p.date_available

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Jul 14, 2010 5:18 am
by mystifier
I actually changed it to p.date_modified which provides a very simple mechanism for controlling the order - to bubble a product to the top, it simply needs to be edited and saved again (even if this is only to delete a character and replace it again).

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Jul 14, 2010 5:59 am
by Johnathan
That works well too, but I didn't want products that I edit the information for (options, categories, etc.) to be bumped to the top of the list. I prefer date_available because you can set it, so it works independently from editing other options. Just my preference.

Also, I originally had this thread in the Feature Requests forum because I think this should be added to the core. Does somebody disagree with me?

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Jul 14, 2010 2:10 pm
by mystifier
Johnathan wrote:Does somebody disagree with me?
I do. ;D

I picked date_modified over date_available because it is greater precision datetime whereas date_available is date and generally, many products get added on the same day.

The fact that you can easily change the date available easily and so change its position to suit makes much more sense than what I did but it may not be possible to use the true date where positional control over multiple products is desired. Out of the three, date_add is by far the least useful.

I have just bowed to your better thinking and changed to date_available but I think it needs a secondary field to sort by.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Jul 14, 2010 9:33 pm
by Qphoria
I did disagree yesterday.. but it sounds better today. Either way, I'll take it under advisement. In the mean time, others will benefit from this more as a mod for now.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Sat Jul 17, 2010 12:05 pm
by Johnathan
Thanks for both your considered responses. I see what you mean about date_modified...for my wife and myself, we just change date_available on products that we don't want as latest products to an earlier day. Of course, if you have lots of products appearing on a single day in the future, that's not as useful. :)

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Tue Oct 12, 2010 7:39 am
by opencartnovice
Johnathan wrote:Thanks for both your considered responses. I see what you mean about date_modified...for my wife and myself, we just change date_available on products that we don't want as latest products to an earlier day. Of course, if you have lots of products appearing on a single day in the future, that's not as useful. :)
I'm in the same side with Johnathan when setting an online store. It is requested that "just arrived items" appear in home page i.e. their data has been already in system but their stock was out, but now back full, and so I change the date as Johnathan's comments. Thanks

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Tue Mar 01, 2011 9:11 pm
by onlinephilately
Hello,

I have tried this but I would like to change it so that the Latest only show products that have been added let's say the last 10 days.

How do I fix this?

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Sat May 28, 2011 3:40 pm
by jules
(I don't know if this thread is still alive or history, but I find it interesting.)
I thank all of you for these brilliant comments and suggestions. I also agree with Mystifier that a 'sort order' will add to the flexibility of this module. Overall, it might just be better to give the administrator some options (date added, date modified, dated available) to chose from according to his or her own convenience. Finally, I suggest one more option - a 'forced' option which lets a particular product persist and show up no matter what. And, like Jonathan suggested, this should make it to the core if possible. Thanks again.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Oct 24, 2012 3:51 am
by matte2k
Johnathan wrote:I think it works a lot better for Latest Products to be based on date_available instead of date_added, since date_available can be changed in the admin. This way products can be created ahead of time and still appear on the correct date as a "latest product". It's an easy fix, too:

IN:

Code: Select all

/catalog/model/catalog/product.php
REPLACE:

Code: Select all

ORDER BY p.date_added
WITH:

Code: Select all

ORDER BY p.date_available
is this the correct way to do it even in 1.5.1.3
cause it doesn't seem to work :(

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Oct 24, 2012 4:11 am
by labeshops
From the date of the original post, I would guess this was done for 1.4, not 1.5.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Oct 24, 2012 4:20 am
by matte2k
labeshops wrote:From the date of the original post, I would guess this was done for 1.4, not 1.5.
Yes me 2..
I guess the correct file in 1.5.1.3 is catalog/controller/module/latest.php.
But when changing to p.date_published the sort order changes but to something totally random :(

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Oct 24, 2012 9:12 pm
by Johnathan
The original change was for 1.4.x versions, but it still works in all 1.5.x versions. Make sure you delete your /system/cache/ files (specifically, the ones that start with product.latest.). It's probably just caching the old product list and using that instead.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Wed Oct 24, 2012 9:20 pm
by matte2k
Ok I will try that!
Is the correct file: I guess the correct file in 1.5.1.3 is catalog/controller/module/latest.php ?
I have a table in the sql databas named "date_published". Should the change then be: "p.date_published"?
What is "p." stands for?

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Thu Oct 25, 2012 3:57 am
by matte2k
nope... that didn't work! :(

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Thu Oct 25, 2012 8:07 pm
by Johnathan
There is no date_published in the default OpenCart, so you must be using a mod or extension. The change in the default OpenCart file is exactly as I've described. You should contact the author of that extension for help adjusting it.

Re: [MOD] Latest Prod use date_available instead of date_add

Posted: Sun May 12, 2013 8:18 pm
by matte2k
I need help!

I want my latest module to show the latest product that I've added to be displayed first.

In catalog/model/catalog/product.php it's written "ORDER BY p.date_added DESC LIMIT"
In catalog/controller/module/product.php it's written "p.date_added"

But it still doesnt display it that way. What am I doing wrong?


edit: I run 1.5.1.3