<?php
use Magento\Framework\App\Bootstrap;
require '/srv/users/serverpilot/apps/55luxe/public/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$str = 'sku1,sku2';
$namepro = 'product name 1,product name 2';
$arraypro = explode(",", $namepro);
$array = explode(",", $str);
$id = [];
$name = [];
foreach ($array as $sku) {
$product = $objectManager->create('Magento\Catalog\Model\Product')->loadByAttribute('sku', $sku);
$id[] = $product->getData('entity_id');
}
foreach ($arraypro as $value) {
$name[] = $value;
}
$data = array_combine($id, $name);
foreach ($data as $key => $newdata) {
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('catalog_product_entity_varchar');
$sql = 'Update ' . $tableName . ' Set value = "' . $newdata . '" where entity_id = "' . $key . '" AND attribute_id = 73';
// attribute 73 is product name ;
$connection->query($sql);
}
use Magento\Framework\App\Bootstrap;
require '/srv/users/serverpilot/apps/55luxe/public/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$str = 'sku1,sku2';
$namepro = 'product name 1,product name 2';
$arraypro = explode(",", $namepro);
$array = explode(",", $str);
$id = [];
$name = [];
foreach ($array as $sku) {
$product = $objectManager->create('Magento\Catalog\Model\Product')->loadByAttribute('sku', $sku);
$id[] = $product->getData('entity_id');
}
foreach ($arraypro as $value) {
$name[] = $value;
}
$data = array_combine($id, $name);
foreach ($data as $key => $newdata) {
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('catalog_product_entity_varchar');
$sql = 'Update ' . $tableName . ' Set value = "' . $newdata . '" where entity_id = "' . $key . '" AND attribute_id = 73';
// attribute 73 is product name ;
$connection->query($sql);
}
Comments
Post a Comment