Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishgumudavelli/7ea3f77ba5b46f0d443e1e65bf018e9b to your computer and use it in GitHub Desktop.
Save satishgumudavelli/7ea3f77ba5b46f0d443e1e65bf018e9b to your computer and use it in GitHub Desktop.
<?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