VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: rado85 on September 04, 2013, 20:25:12 PM

Title: Multilangual Shop! Problem with create-date in database
Post by: rado85 on September 04, 2013, 20:25:12 PM
Hi, i wrote before about this iritaiting problem. but now i know much more.

I have multi language store where is problem with latest products module.

i found out that when i translate product it stop displaying in latest products. Even when i sort category by date it is on last position!

The reason of that is - in the moment i translate product in database in table virtuemart_products "created_on" is 0000000;00000;0;0;0. When i manually set date it is ok.

Can you tell me how to fix this problem ?
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: rado85 on September 06, 2013, 04:50:20 AM
Now i updated Joomla 2.5.14 and VM 2.20C.

I Makes translation for product -> Save (save succesfull info) and... nothing hapen. The translations doesn`t save. when i chose language again there is info "No translation for this product" Something is wrong with database ...
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: Maxim Pishnyak on September 14, 2013, 13:06:31 PM
You need to try last version of VM - 2.0.22d.
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: rvbgnu on November 24, 2013, 13:28:28 PM
Hi,
I have the same problem here with a multilangual shop.
creation date OK when cloning product, I have the alert message about the other language does not exist. BUT the creation_date is changed to '0000-00-00 00:00:00' when I save the product translation!!

Joomla 2.5.16
VM 2.0.24
Default back-end template.

Any idea?
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: Peter Pillen on November 24, 2013, 14:21:37 PM
Think I found it

file: administrator\components\com_virtuemart\helpers\vmtable.php

in the function setLoggableFieldsForStore() @ line382


search for...

//If nothing is there, dont update it
$this->created_on = null;

This line is written there three times in this function and replace them with

unset($this->created_on);

Because the comment line says "If nothing is there, dont update it" but saying $this->created_on = null to achieve that, does not eliminate the variable ... it just changes it into "0000-00-00 00:00:00". In that function the're still a couple more lines like that.
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: rvbgnu on November 24, 2013, 16:03:28 PM
Hi P2 Peter,

Well done Man! It is fixed!! Thank you!

However, I have only found two instances of
$this->created_on = null;

and I have also changed, to keep code consistency
$this->created_by = null;
to
unset($this->created_by);

So NOW I have, at last, correct "Latest products" displayed!

It is time to commit this to the Core code VM Devs ;-) and maybe this way to eliminate a variable, for other variables, is used in somewhere else in the code and cause trouble... I will let the experts check for it.

So Peter, I owe you one (beer)  ;)
Sláinte!
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: Peter Pillen on November 24, 2013, 16:11:45 PM
I'm not sure if this would cause problems for other variables because it just incorrect to say $this->created_on = null,  because null is an accepted value for that field.

QuoteHowever, I have only found two instances of $this->created_on = null

Tip: If you're coding and only found two instances ... always tell the others they're three of them. You never know you missed one yourself  ;D

* whoop ... just lost my free beer now *
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: rvbgnu on November 24, 2013, 16:21:28 PM
... or because you started with a few pints before me, so you see "three instead of two"...  :P

More seriously, not only your pint is still on, but you might have another one coming, once I have tested your fix for this annoying and long lasting bug
http://forum.virtuemart.net/index.php?topic=96784.msg408999#msg408999
[/END of cross posting]
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: Peter Pillen on November 24, 2013, 16:27:27 PM
Aha! Not many people responded on that one, but at this moment that fix also works pretty well (needs further improvement though). But lets stay on the subject of this topic ... two beers you were saying?  :)
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: rvbgnu on November 24, 2013, 19:24:03 PM
(yes, if you come over to Ireland, let me know... or maybe we should find another way, it may not happen, and I do not promise something I could not keep 8)

BUT there is a side effect AFTER this fix: the next modification to a product with a null *created_on* date field (0000-00-00 00:00:00) will set it to the current modification timestamp. There after, the *created_on* will not change, according to my few tests (on a copy of a live and real shop).
SO we are better adding some date on the field sooner than later, even with the same for all. Otherwise, every modified product with a null creation date will be seen among "latest products"...

Working on a SQL for PhpMyadmin to do this
Title: Re: Multilangual Shop! Problem with create-date in database
Post by: Peter Pillen on November 24, 2013, 19:51:15 PM
Due to time-shortage I wasn't able to test this code completely, but I suspected something like that. Nothing checks if a product already had a good timestamp. But I will look into it later on.