I'm struggling to set the order date when creating a magento order programatically.
Here is what I'm trying to use:
$orderObj->setData('created_at', $date); $orderObj->setUpdatedAt($date);
but it doesn't appear to work.
Thank you in advance!
datemagento-1.8orders
I'm struggling to set the order date when creating a magento order programatically.
Here is what I'm trying to use:
$orderObj->setData('created_at', $date); $orderObj->setUpdatedAt($date);
but it doesn't appear to work.
Thank you in advance!
Best Answer
created_at
andupdated_at
for orders is set inMage_Sales_Model_Resource_Abstract::_prepareDataForSave()
:You can see that
updated_at
is always set to the current time, whereascreated_at
is only set if the attribute is empty. The format that it should have comes fromVarien_Date
.So you should be able to define your own creation timestamp:
where
$date
can be a Unix timestamp or an arbitrary date expression that can be parsed with PHPsstrtotime