| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | Mark Forums Read | User manuals | Login |
Date as column type? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Date as column type?
I am writing a module with custom model, whose entities have dates as property.
It looks like x-cart handles dates as integers via timestamp, but I will be importing the entities from a CSV file, in which they are entered as dates. So my question is, can we do something like Code:
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Date as column type?
Sure you can. But then you will have to covert it to timestamp every time you need to use it (or within its get method) unless you create your own controls to work with this field.
It is probably best to just either modify the csv file and covert the dates to timestamp or do this on the fly with the import.
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#3
|
|||||||
|
|||||||
Re: Date as column type?
It turns out the things are a bit more complicated. The FormField class
View/FormField/Input/Text/Date.php, as its path suggests, treats dates as strings. So, I can't do Code:
and use View/FormField/Input/Text/Date.php for editing the entity, i.e. Code:
The only place, it seems to me, where there is the date to be input manually in X-Cart's original code, is the arrival date for products, but there, the class View/FormModel/Type/DatepickerType.php is used. My entities don't use the DTO, so I can't use this class. So, the question now is: how do I get around this problem? I would need something like Code:
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#4
|
|||||||
|
|||||||
Re: Date as column type?
I have found out a bit more. If I want to use XLite\View\FormField\Input\Text\Date and I use the date as the data type, then
the following code for setter works. Code:
Code:
for the formats 09-18-2019, 18.09.2019, 18-09-2019. Any idea on how to solve this?
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#6
|
|||||||
|
|||||||
Re: Date as column type?
Now it only works for 4 out of 8 formats. I don't know if this is because of x-cart update to 5.4.0.8 or upgrade of php/mariadb/apache or whatsoever server component, but the format 19-12-2019 (the one we were using!) works no longer.
Any idea where this comes from and how to solve it, other than switching the format?
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#7
|
|||||||
|
|||||||
Re: Date as column type?
Quote:
Thank you very much, but
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#8
|
|||||||
|
|||||||
Re: Date as column type?
It now only works for four out of eight formats. It doesn't seem to be due to the latest version of X-Cart, nor has it been changed by any recent software updates. You may want to contact our support team for assistance.
* @Column (type="integer") */ protected $mydate public getMydate { return $this->mydate } public setMydate($value) { $this->mydate=$value; return $this; } Regards Ways101
__________________
Ways101.com |
|||||||
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|