Created
July 8, 2022 16:27
-
-
Save satishgumudavelli/7ea3f77ba5b46f0d443e1e65bf018e9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Need to add this script and csv in var/shell folder */ | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
ini_set('memory_limit', '5G'); | |
error_reporting(E_ALL); | |
set_time_limit(0); | |
use Magento\Catalog\Api\Data\ProductInterface; | |
use Magento\Catalog\Model\Product; | |
use Magento\Eav\Model\ResourceModel\AttributeValue; | |
use Magento\Framework\App\Bootstrap; | |
use Magento\Framework\App\ObjectManager; | |
require __DIR__ . '/../../app/bootstrap.php'; | |
$params = $_SERVER; | |
$bootstrap = Bootstrap::create(BP, $params); | |
$obj = $bootstrap->getObjectManager(); | |
$state = $obj->get('Magento\Framework\App\State'); | |
$state->setAreaCode('frontend'); | |
$scopeConfig = $obj->get(\Magento\Framework\App\Config\ScopeConfigInterface::class); | |
$encryptor = $obj->get(\Magento\Framework\Encryption\EncryptorInterface::class); | |
$customerRegistry = $obj->get(\Magento\Customer\Model\CustomerRegistry::class); | |
$customerRepository = $obj->get(\Magento\Customer\Api\CustomerRepositoryInterface::class); | |
$sessionCleaner = $obj->get(\Magento\Customer\Api\SessionCleanerInterface::class); | |
$newPassword = 'NewPassword'; | |
$customerId = '144652'; | |
$customer = $customerRepository->getById($customerId); | |
$customer = $customerRepository->get() | |
$customerSecure = $customerRegistry->retrieveSecureData($customerId); | |
$customerSecure->setRpToken(null); | |
$customerSecure->setRpTokenCreatedAt(null); | |
$customerSecure->setPasswordHash($encryptor->getHash($newPassword, true)); | |
$sessionCleaner->clearFor((int)$customerId); | |
$customerRepository->save($customer); | |
echo "Succesfully saved " . $customer->getEmail() . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment