Test class for product and pricebook:
Product2 prod = new Product2(Name = 'Laptop X200',
Family = 'Hardware');
insert prod;
Id pricebookId = Test.getStandardPricebookId();
PricebookEntry standardPrice = new PricebookEntry(
Pricebook2Id = pricebookId, Product2Id = prod.Id,
UnitPrice = 10000, IsActive = true);
insert standardPrice;
Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
insert customPB;
PricebookEntry customPrice = new PricebookEntry(
Pricebook2Id = customPB.Id, Product2Id = prod.Id,
UnitPrice = 12000, IsActive = true);
insert customPrice;
List<PricebookEntry> pbez = [SELECT ID, Product2Id, Pricebook2.isStandard, Pricebook2.isActive, isActive FROM PricebookEntry];
system.debug(pbez[0].Pricebook2.isStandard);
system.debug(pbez[0].Pricebook2.isActive);
Product2 prod = new Product2(Name = 'Laptop X200',
Family = 'Hardware');
insert prod;
Id pricebookId = Test.getStandardPricebookId();
PricebookEntry standardPrice = new PricebookEntry(
Pricebook2Id = pricebookId, Product2Id = prod.Id,
UnitPrice = 10000, IsActive = true);
insert standardPrice;
Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
insert customPB;
PricebookEntry customPrice = new PricebookEntry(
Pricebook2Id = customPB.Id, Product2Id = prod.Id,
UnitPrice = 12000, IsActive = true);
insert customPrice;
List<PricebookEntry> pbez = [SELECT ID, Product2Id, Pricebook2.isStandard, Pricebook2.isActive, isActive FROM PricebookEntry];
system.debug(pbez[0].Pricebook2.isStandard);
system.debug(pbez[0].Pricebook2.isActive);
No comments:
Post a Comment