Please find the code i have written below.but it has errors .can anyone please help me with it. global class ProductsAndPricebooksAndEntry { public List<ProdctsInfo> info{get;set;} // This is our wrapper/container class. global class ProdctsInfo {
webservice static List<Product2> createProduct(List<ProdctsInfo> info) { //Our collection of the Product objects List<Product2> pro = new List<Product2>(); List<Pricebook2> pricebookList=new List<Pricebook2>(); for(ProdctsInfo i:info){ Product2 product =new Product2(); product.name=i.name; product.Product_Type__c= i.type; product.Product_Category__c= i.category; product.Product_Price__c=i.price; // As each ProductsInfo is processed we create a new Product object and add it to the ProductList pro.add(product); Pricebook2 pb=new Pricebook2(); pb.Name=String.valueOf(i.pricebookName); pricebookList.add(pb);
global class ProductsAndPricebooksAndEntry {
public List<ProdctsInfo> info{get;set;}
// This is our wrapper/container class.
global class ProdctsInfo {
webservice String name;
webservice String type;
webservice String category;
webservice Decimal price;
webservice Pricebook2 pricebookName;
webservice PricebookEntry pricebookentryName;
}
webservice static List<Product2> createProduct(List<ProdctsInfo> info) {
//Our collection of the Product objects
List<Product2> pro = new List<Product2>();
List<Pricebook2> pricebookList=new List<Pricebook2>();
for(ProdctsInfo i:info){
Product2 product =new Product2();
product.name=i.name;
product.Product_Type__c= i.type;
product.Product_Category__c= i.category;
product.Product_Price__c=i.price;
// As each ProductsInfo is processed we create a new Product object and add it to the ProductList
pro.add(product);
Pricebook2 pb=new Pricebook2();
pb.Name=String.valueOf(i.pricebookName);
pricebookList.add(pb);
PricebookEntry pbe=new PricebookEntry();
// pbe.Name=string.valueOf(i.pricebookentryName);
}
insert pro;
insert pricebookList;
return pro;
}
}