Read the following steps and do it.
Step 1:
Edit file ../config/settings.inc.php , and add :
Step 1:
Edit file ../config/settings.inc.php , and add :
define('_COOKIE_KEY_OLD_', 'YOUR_PS_V.1.4.9_COOKIE_KEY_');
Step 2:
Edit file ../override/classes/Customer.php, and add :
public function getByEmail_old($email, $passwd = null, $ignore_guest = true)
{
if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd)))
die (Tools::displayError());
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'customer`
WHERE `email` = \''.pSQL($email).'\'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt_old($passwd).'\'' : '').'
AND `deleted` = 0'.
($ignore_guest ? ' AND `is_guest` = 0' : '');
$result = Db::getInstance()->getRow($sql);
if (!$result)
return false;
$this->id = $result['id_customer'];
foreach ($result as $key => $value)
if (key_exists($key, $this))
$this->{$key} = $value;
return $this;
}
Step 3 :
Edit file ../override/classes/Tools.php, and add :
public static function encrypt_old($passwd)
{
return md5(_COOKIE_KEY_OLD_.$passwd);
}
Step 4:
Edit file ../override/controllers/front/AuthController.php, and add :
protected function processSubmitLogin()
{
Hook::exec('actionBeforeAuthentication');
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
if (empty($email))
$this->errors[] = Tools::displayError('E-mail address required');
elseif (!Validate::isEmail($email))
$this->errors[] = Tools::displayError('Invalid e-mail address');
elseif (empty($passwd))
$this->errors[] = Tools::displayError('Password is required');
elseif (!Validate::isPasswd($passwd))
$this->errors[] = Tools::displayError('Invalid password');
else
{
$customer = new Customer();
$authentication = $customer->getByEmail(trim($email), trim($passwd));
$authentication_old = $customer->getByEmail_old(trim($email), trim($passwd));
if ((!$authentication AND !$authentication_old) || !$customer->id)
$this->errors[] = Tools::displayError('Authentication failed');
else
{
$this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
$this->context->cookie->id_customer = (int)($customer->id);
$this->context->cookie->customer_lastname = $customer->lastname;
$this->context->cookie->customer_firstname = $customer->firstname;
$this->context->cookie->logged = 1;
$customer->logged = 1;
$this->context->cookie->is_guest = $customer->isGuest();
$this->context->cookie->passwd = $customer->passwd;
$this->context->cookie->email = $customer->email;
// Add customer to the context
$this->context->customer = $customer;
if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0))
$this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id);
// Update cart address
$this->context->cart->id = $this->context->cookie->id_cart;
$this->context->cart->setDeliveryOption(null);
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->secure_key = $customer->secure_key;
$this->context->cart->update();
$this->context->cart->autosetProductAddress();
Hook::exec('actionAuthentication');
// Login information have changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
if (!$this->ajax)
{
if ($back = Tools::getValue('back'))
Tools::redirect(html_entity_decode($back));
Tools::redirect('index.php?controller=my-account');
}
}
}
if ($this->ajax)
{
$return = array(
'hasError' => !empty($this->errors),
'errors' => $this->errors,
'token' => Tools::getToken(false)
);
die(Tools::jsonEncode($return));
}
else
$this->context->smarty->assign('authentification_error', $this->errors);
}
Finally
Create csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database
Done :)
Hi, thanks for this awesome post, but I have some questions. Need I write all this code in the 1.4.9 prestashop or 1.5.X prestashop? How can I create csv file to update XX_customer_group table database for all id_customer set group to 3 (customer), and import to your Prestashop database? Thanks you very much.
ReplyDeleteyou write all this code in the 1.5.X prestashop. Create csv file using your database control panel.
Deletethnx
Its will be same for PS 1.6 ?
ReplyDelete