Joomla 2.5.8
Virtuemart 2.0.14
Situation
I had filled my virtuemart categories with about 300 products. I had the French and English languages all set up beforehand. But after I translated all my articles/products, the creation date was lost. This causes my product ordering by creation date to fail, also the "latest products" module does not display anything.
Proof
I have checked my phpmyadmin tables, and the "created_on" fields of every record (except the products I missed to translate) in the table "virtuemart_products", where set to "0000-00-00 00:00:00". I even did a clean install of virtuemart, but the problem persists.
I will change the cration dates manually in the database with phpadmin now, but if someone can check if this is a bug or not, it would be a great help. I sometimes change code in the core files, but not anything related to these creation dates.
Temporary solution: updating the tables in the database directly with mysql statement after translation
UPDATE `database name`.`XXX_virtuemart_products` SET `created_on` = `modified_on`;
this overwrites all the creation dates to the modified dates.
* bump *
could anyone check if they have this problem too? If i'm the only one with this problem, I need to check my files again.
Is there anyone with the same problem?
Could someone give me some directions to which files could be causing this problem? I know the creation date upon copying a product was fixed in the latest version of virtuemart, but maybe the problem persists in the translation of the products.
Interesting problem. Maybe it is similar like the copy, yes. If you want to investigate yourself, take a look on vmtables and there the store function. you may learn how to use vmdebug, makes it easier. IF you are fast enough, we can add it to 2.0.16
I see in VMdebug that the function "bindChecknStoreNoLang" is used to store the new languagevariant. But I don't see any reference to the the date of the product. Probably the date is overwritten in some other manner.
Vm debug shows me thee following message (this is the moment the date is lost)
vmdebug self::$_jpConfig->lang en_gb
vmdebug vmTime: loadConfig db no: 0.0041069984436035
vmdebug bindChecknStoreNoLang my $tblKey virtuemart_product_id 401
vmdebug self::$_jpConfig->lang nl_nl
vmdebug vmTime: loadConfig db no: 0.0039050579071045
vmdebug VirtuemartViewProduct edit
Could it be that the created_on field is set as non loggable? Because the function "store" only uses fields that logged...
file: /administrator/components/com_virtuemart/helpers/vmtable.php
function store($updateNulls = false){
$this->setLoggableFieldsForStore(); //<-- only logged fields?
$this->storeParams();
return parent::store($updateNulls);
}
and somewhere up in the document I see
public function setLoggable(){
$this->_loggable = true;
$this->created_on = false; //<-- creation date and time is not logged?
$this->created_by = 0;
$this->modified_on = '';
$this->modified_by = 0;
}
I tried different things, but no luck :(
Nope... I can't find the problem. I probably missing but 5 IQ to solve this puzzle, but i'm not getting any smarter.
I can only guess that vmtable.php doesn't take the created_on date along in the function for the first translation in a new language (because when I do a second update of that language, the date does not change).
so unfortunatly... NO solution
Okay... I need some help in solving this problem and I can't imagine no one else is experiencing problems with this ... although most sites only use one language, I don't have that luxury and I need three languages.
This error causes the Latest products module to fail and makes it impossible to sort products on creation date in all multilingual virtuemart sites. Sure this must be important for more users than just me?
I have the same problem - http://forum.virtuemart.net/index.php?topic=104597.msg347910#msg347910
Empty value number of fields is in many cases, my temporary solution is creating Mysql triggers
Can someone confirm this fix/solution please? Because it seems to work here, although it looks as a caveman fix ... "just hit it" ;D
file /administrator/components/com_virtuemart/helpers/vmtable.php
I added a check for an empty created_on field in the function setLoggableFieldsForStore() and if so, re-use the variable $this->$today
if($this->created_on=="0000-00-00 00:00:00"){
$this->created_on = $this->$today;
}
it is placed @line 265 (see below)
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
$admin = Permissions::getInstance()->check('admin');
if($admin){
if(empty($this->$pkey) and empty($this->created_on)){
$this->created_on = $today;
}
if(empty($this->$pkey) and empty($this->created_by)){
$this->created_by = $user->id;
}
} else {
if(empty($this->$pkey)){
$this->created_on = $today;
$this->created_by = $user->id;
}
}
//ADDED BY P2 PETER
if($this->created_on=="0000-00-00 00:00:00"){
$this->created_on = $this->$today;
}
//END ADD
$this->modified_on = $today;
$this->modified_by = $user->id;
of course this means that somewhere the created_on variable is set to zero, what remains a mistery :-\
I just noticed that the created_on dates of the manufacturers is also 0000-00-00 00:00:00 over all of them. Not that it has any function, but it all points to one bigger problem.
Good idea. Added.
What is the status of this problem ?
I'm still seeing this problem with a site on version 2.0.20b
and 2.0.22a? in general it is considered as fixed.
Think I found it
file: administrator\components\com_virtuemart\helpers\vmtable.php
in the function setLoggableFieldsForStore() @ line382
search for...
$this->created_on = null;
This line is written there three times in this function and replace it 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.
sounds good, thanks.