After a long debug, Issue has get resolved. It was happening due to trigger_recollect
field in quote.
Class Mage_Sales_Model_Resource_Quote.php
I have put if($data['trigger_recollect'] == 1){ }
in loadByCustomerId method.
Customer those have $data['trigger_recollect'] = 0
were not able to logged in.
updated method
/**
* Load quote data by customer identifier
*
* @param Mage_Sales_Model_Quote $quote
* @param int $customerId
* @return Mage_Sales_Model_Resource_Quote
*/
public function loadByCustomerId($quote, $customerId)
{
$adapter = $this->_getReadAdapter();
$select = $this->_getLoadSelect('customer_id', $customerId, $quote)
->where('is_active = ?', 1)
->order('updated_at ' . Varien_Db_Select::SQL_DESC)
->limit(1);
$data = $adapter->fetchRow($select);
// additional code
if($data['trigger_recollect'] == 1){
$entityIds = $this->_getReadAdapter()->fetchCol($select);
// Mage::log($entityIds,null,'customAmit.log');
if (count($entityIds) > 0) {
$where = $this->_getWriteAdapter()->quoteInto('entity_id IN (?)', $entityIds);
$this->_getWriteAdapter()->update($this->getTable('sales/quote'), array('trigger_recollect' => 0), $where);
}
}
// additional code
if ($data) {
$quote->setData($data);
}
$this->_afterLoad($quote);
return $this;
}