首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento 1.9错误的客户创建和最后登录日期

Magento 1.9错误的客户创建和最后登录日期
EN

Stack Overflow用户
提问于 2015-02-11 12:52:47
回答 3查看 4K关注 0票数 6

我正在运行Magentov.1.9.0.1,在通过管理区域编辑客户时,我面临一个显示日期的问题。例如,

最后登录:11,2月11日, 4:23:48μ.μ。

最后登录(欧洲/伊斯坦布尔):09 2015年2月9日 3:16:31μ.μ。

创建账户:02,2015年9月2日, 4:16:11μ.μ。

客户于2015年2月9日登记。我四处搜索,发现了关于其他Magento版本的主题,这些版本说有些日期Magento正在交换日期,因此实际创建日期(09/02/2015)和报告创建日期(02/09/2015)之间的差别。

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

这个问题有解决办法吗?

谢谢您抽时间见我。

EN

回答 3

Stack Overflow用户

发布于 2015-06-05 12:04:57

在Magento1.8.1中也遇到了同样的问题,并在下面的解决方案中为帐户创建的日期和最后登录date.Because应用了一些Magento是如何在客户编辑部分逐月转换的。Path:app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\View.php覆盖上面文件中的以下方法:

代码语言:javascript
复制
    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');
    }
票数 1
EN

Stack Overflow用户

发布于 2016-05-16 06:05:53

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

Magento扩展名中用于解决Magento日期切换的文件摘要-- Fix: Created.php: Created.php

代码语言:javascript
复制
    <?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

代码语言:javascript
复制
<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/模块/ CustomerParadigm_Datefix.xml

代码语言:javascript
复制
<?xml version=”1.0″?>
<config>
<modules>
<CustomerParadigm_Datefix>
<active>true</active>
<codePool>local</codePool>
</CustomerParadigm_Datefix>
</modules>
</config>
票数 1
EN

Stack Overflow用户

发布于 2015-12-14 14:39:16

我没有什么名望可以评论,所以我通过回应指出:

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

代码语言:javascript
复制
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条件,这个参数是否正确:

代码语言:javascript
复制
if ($date = $this->getCustomerLog()->getLoginAtTimestamp())

我不这么认为,你是在抨击,那怎么才是正确的呢?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28454879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档