Skip to content

Commit

Permalink
PHP 8.1: replaced deprecated gmstrftime() with gmdate() (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
elidrissidev authored and fballiano committed Jan 16, 2023
1 parent 45e7b10 commit 03ad211
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ protected function _saveCustomers()
{
/** @var Mage_Customer_Model_Customer $resource */
$resource = Mage::getModel('customer/customer');
$strftimeFormat = Varien_Date::convertZendToStrftime(Varien_Date::DATETIME_INTERNAL_FORMAT, true, true);
$table = $resource->getResource()->getEntityTable();
/** @var Mage_ImportExport_Model_Resource_Helper_Mysql4 $helper */
$helper = Mage::getResourceHelper('importexport');
Expand Down Expand Up @@ -392,7 +391,7 @@ protected function _saveCustomers()
'store_id' => empty($rowData[self::COL_STORE])
? 0 : $this->_storeCodeToId[$rowData[self::COL_STORE]],
'created_at' => empty($rowData['created_at'])
? $now : gmstrftime($strftimeFormat, strtotime($rowData['created_at'])),
? $now : gmdate(Varien_Date::DATETIME_PHP_FORMAT, strtotime($rowData['created_at'])),
'updated_at' => $now
];

Expand Down Expand Up @@ -424,7 +423,7 @@ protected function _saveCustomers()
if ($attrParams['type'] === 'select') {
$value = $attrParams['options'][strtolower($value)];
} elseif ($attrParams['type'] === 'datetime') {
$value = gmstrftime($strftimeFormat, strtotime($value));
$value = gmdate(Varien_Date::DATETIME_PHP_FORMAT, strtotime($value));
} elseif ($attrParams['type'] === 'multiselect') {
$value = (array)$attrParams['options'][strtolower($value)];
$attribute->getBackend()->beforeSave($resource->setData($attrCode, $value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ protected function _importData()
$customer = Mage::getModel('customer/customer');
/** @var Mage_Customer_Model_Address $resource */
$resource = Mage::getModel('customer/address');
$strftimeFormat = Varien_Date::convertZendToStrftime(Varien_Date::DATETIME_INTERNAL_FORMAT, true, true);
$table = $resource->getResource()->getEntityTable();
/** @var Mage_ImportExport_Model_Resource_Helper_Mysql4 $helper */
$helper = Mage::getResourceHelper('importexport');
Expand Down Expand Up @@ -201,7 +200,7 @@ protected function _importData()
if ($attrParams['type'] === 'select') {
$value = $attrParams['options'][strtolower($rowData[$attrAlias])];
} elseif ($attrParams['type'] === 'datetime') {
$value = gmstrftime($strftimeFormat, strtotime($rowData[$attrAlias]));
$value = gmdate(Varien_Date::DATETIME_PHP_FORMAT, strtotime($rowData[$attrAlias]));
} elseif ($attrParams['type'] === 'multiselect') {
$value = $attrParams['options'][strtolower($rowData[$attrAlias])];
$multiSelect[$attrParams['id']][] = $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ protected function _saveProducts()
/**
* Retrieve pattern for time formatting
*
* @deprecated
* @return string
*/
protected function _getStrftimeFormat()
Expand Down Expand Up @@ -1569,7 +1570,7 @@ protected function _prepareAttributes($rowData, $rowScope, $attributes, $rowSku,
$storeIds = [0];

if ($attribute->getBackendType() === 'datetime' && strtotime($attrValue)) {
$attrValue = gmstrftime($this->_getStrftimeFormat(), strtotime($attrValue));
$attrValue = gmdate(Varien_Date::DATETIME_PHP_FORMAT, strtotime($attrValue));
} elseif ($attribute->getAttributeCode() === 'url_key') {
if (empty($attrValue)) {
$attrValue = $product->formatUrlKey($product->getName());
Expand Down

0 comments on commit 03ad211

Please sign in to comment.