%PDF- %PDF-getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('adminhtml'); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $fileA = fopen("url_rewrite.csv","r"); while (($row = fgetcsv($fileA, 1000, ",")) !== FALSE) { $productId = $row[1]; $rewriteVal = $row[2]; if($productId != '' && $rewriteVal !='') { $product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); #$product->setWebsiteIds(array(1,2)); $product->setUrlKey($rewriteVal); $product->save(); echo $productId ." => ".$rewriteVal." = Product Saved.
"; print_r($product->getData());
}
} */
#$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
#$connection = $resource->getConnection();
#$tableName = $resource->getTableName('url_rewrite'); //gives table name with prefix
//Select Data from table
#echo $sql = "Select * FROM " . $tableName. " WHERE entity_id = 242";
#$result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.
#echo ""; print_r($result);
//Update Data into table
#$sql = "Update " . $tableName . "Set emp_salary = 20000 where emp_id = 12";
#$connection->query($sql);
/* $fileW = fopen("sku_id.csv","w");
foreach ($collection as $product){
$line = array($product->getSku(),$product->getId());
fputcsv($fileW, $line);
} */
?>