1

Suddenly, I am getting incorrect 'Last Logged In' date magento admin panel for edit customer..It is showing date with a year which is unexpected. I am not sure if there also happening any issues with date.. Do anyone know why this is happening suddenly? This is happening to magento 1.8 and magento 1.9.1 please help!

3
  • You can check a similar question magento.stackexchange.com/questions/38143/… Commented Dec 7, 2015 at 10:26
  • @RahulKumarDas: Can you please tell me the complete steps here to override this instead of changing the code in core? Commented Dec 7, 2015 at 12:00
  • @RahulKumarDas: If I am following the way you told then that is keeping single result of logged-in details based on the condition in app/design/adminhtml/default/default/template/customer/tab/view.phtml but I wanted it to display both based on i.e., both logged-in labels Any idea on this will be helpful for me to get this done! Commented Dec 7, 2015 at 12:04

1 Answer 1

2

After several search, I found a way to override the class's functionality which is responsible of calculating date:

Package name: Custom
Module name: Datefix

I have created 3 files to achieve this:

  • app/etc/modules/Custom_Datefix.xml
  • app/etc/code/local/Custom/Datefix/etc/config.xml
  • app/etc/code/local/Custom/Datefix/Block/Customer/Edit/Tab/View.php

Codes:

app/etc/modules/Custom_Datefix.xml :

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * @category   Custom
 * @package    Custom_Datefix
 */
-->
<config>
    <modules>
        <Custom_Datefix>
            <version>1.0.0</version>
        </Custom_Datefix>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <customer_edit_tab_view>Custom_Datefix_Block_Customer_Edit_Tab_View</customer_edit_tab_view>
                </rewrite>
            </adminhtml>
        </blocks>        
    </global>
</config>

app/etc/code/local/Custom/Datefix/etc/config.xml :

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * @category   Custom
 * @package    Custom_Datefix
 */
-->
<config>
    <modules>
        <Custom_Datefix>
            <version>1.0.0</version>
        </Custom_Datefix>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <customer_edit_tab_view>Custom_Datefix_Block_Customer_Edit_Tab_View</customer_edit_tab_view>
                </rewrite>
            </adminhtml>
        </blocks>        
    </global>
</config>

app/etc/code/local/Custom/Datefix/Block/Customer/Edit/Tab/View.php :

<?php

/**
 * Magento
 *
 *
 * Customer account form block
 *
 * @category   Custom
 * @package    Custom_Datefix
 */
class Custom_Datefix_Block_Customer_Edit_Tab_View
    extends Mage_Adminhtml_Block_Customer_Edit_Tab_View
{
    /**
     * Get customer last login date
     *
     * @return string
     */
    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');
    }
}

Please comment if anyone have any other idea to achieve the same.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.