Magento 1.9错误的客户创建日期和上次登录日期



我正在运行Magento v.1.9.0.1,在通过管理区域编辑客户时,我遇到了日期显示问题。例如,

上次登录时间:7791年2月11日4:23:48μ.μ。
上次登录(欧洲/伊斯坦布尔):2015年2月9日3:16:31μ.μ。
账户创建日期:2015年9月2日4:16:11μ.μ.

客户于2015年2月9日注册。我四处搜索,发现了关于其他Magento版本的主题,这些主题说Magento在某些日期交换了日期,因此实际创建日期(2015年2月9日)和报告创建日期(2014年9月2日)之间存在差异。

我找不到任何关于1.9版本的信息,也找不到关于上次登录的年份(7791!)的信息。

这个问题有解决办法吗?

谢谢你抽出时间。

在Magento 1.8.1中面临同样的问题,并应用以下解决方案来确定帐户创建日期和上次登录日期。因为有些Magento是如何在客户编辑部分将日期转换为月份和月份。路径:appcodecoreMageAdminhtmlBlockCustomerEditTabView.php从上面的文件覆盖下面的方法:

    public function getCreateDate()
    {
        $cutomerId = $this->getRequest()->getParam('id');
        $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
        $select = $connection->select()
                  ->from('customer_entity', array('created_at'))  
                  ->where('entity_id=?',$cutomerId);    
        $rowArray = $connection->fetchRow($select);        
        return $this->_getCoreHelper()->formatDate($rowArray['created_at'],
            Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
    }
    public function getStoreCreateDate()
    {
        $cutomerId = $this->getRequest()->getParam('id');
        $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
        $select = $connection->select()
                  ->from('customer_entity', array('created_at'))
                  ->where('entity_id=?',$cutomerId);
        $rowArray = $connection->fetchRow($select); 
        return $this->_getCoreHelper()->formatDate($rowArray['created_at'],
            Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
    }
    public function getLastLoginDate()
    {
       if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
            $date = Mage::app()->getLocale()->storeDate(
                $this->getCustomer()->getStoreId(),
                $date,
                true
            );
            return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
        }
        return Mage::helper('customer')->__('Never');
    }

在找到解决方案之前,我也曾长期面临同样的问题http://www.customerparadigm.com/magento-bug-magento-customer-create-date-juxtaposition/

Magento扩展中用于解决Magento日期切换修复的文件摘要:Created.php:app/code/local/CustomerParadigm/Datefix/Model/Entity/Attribute/Backend/Time/Created.php

    <?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 // * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage_Eav
 * @copyright  Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/**
 * Entity/Attribute/Model - attribute backend default
 *
 * @category   Mage
 * @package    Mage_Eav
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class CustomerParadigm_Datefix_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
{
    /**
     * Returns date format if it matches a certain mask.
     * @param $date
     * @return null|string
     */
/* This shouldn't be needed for the datetime switch bug fix. Removing for testing.
    protected function _getFormat($date)
    {
        if (is_string($date) && preg_match('#^d{4,4}-d{2,2}-d{2,2} d{2,2}:d{2,2}:d{2,2}$#', $date)) {
            return 'yyyy-MM-dd HH:mm:ss';
        }
        return null;
    }
*/
    /**
     * Set created date
     * Set created date in UTC time zone
     *
     * @param Mage_Core_Model_Object $object
     * @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
     */
    public function beforeSave($object)
    {
        $attributeCode = $this->getAttribute()->getAttributeCode();
        $date = $object->getData($attributeCode);
        if (is_null($date)) {
            if ($object->isObjectNew()) {
                $object->setData($attributeCode, Varien_Date::now());
            }
        } else {
        // Date switch fix
            $date = strtotime($date);
            // convert to UTC
            $zendDate = Mage::app()->getLocale()->utcDate(null, $date, true);
            $object->setData($attributeCode, $zendDate->getIso());
        }
        return $this;
    }
    /**
     * Convert create date from UTC to current store time zone
     *
     * @param Varien_Object $object
     * @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
     */
    public function afterLoad($object)
    {
        $attributeCode = $this->getAttribute()->getAttributeCode();
        $date = $object->getData($attributeCode);
    // Date switch fix
    if (!is_null($date)) {
        $date = strtotime($date);
    }
        $zendDate = Mage::app()->getLocale()->storeDate(null, $date, true);
        $object->setData($attributeCode, $zendDate->getIso());
        parent::afterLoad($object);
        return $this;
    }
}

app/code/local/CustomerParadigm/Datefix/etc/config.xml

<config>
    <global>
        <models>
            <eav>
                <rewrite>
                    <entity_attribute_backend_time_created>CustomerParadigm_Datefix_Model_Entity_Attribute_Backend_Time_Created</entity_attribute_backend_time_created>
                </rewrite>
            </eav>
        </models>
    </global>
</config>

/app/etc/module/CustomerParadigm_Datefix.xml

<?xml version=”1.0″?>
<config>
<modules>
<CustomerParadigm_Datefix>
<active>true</active>
<codePool>local</codePool>
</CustomerParadigm_Datefix>
</modules>
</config>

我没有太多的声誉可以评论,所以通过回复指出:

@Digisha:你已经为getLastLoginDate() 提到了这一点

public function getLastLoginDate()
{
    if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
        $date = Mage::app()->getLocale()->storeDate(
        $this->getCustomer()->getStoreId(),
        $date,
        true
    );
    return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}
return Mage::helper('customer')->__('Never');
}

我只是想问一下,如果条件为,这是否是正确的参数

if ($date = $this->getCustomerLog()->getLoginAtTimestamp())

我不这么认为,你在抱怨,那么这怎么正确呢??

最新更新