I am currently developing a csv importer for our Salesforce to deal with our way of quoting items, and I am currently trying to make it so that if the product has been added in, it detects whether there's duplicate.
This is a snipped of the code i've got so far, however, the Select statement I can't seem to get working.
for(Integer i=1; i < csvFileLines.size(); i++){
Product2 proObj = new Product2() ;
String[] csvRecordData = csvFileLines[i].split(',');
proObj.name = csvRecordData[0] ;
if([SELECT Count() FROM Product2 WHERE Name = :proObj.name[i]]==0) {
productlist.add(proObj);
}
}