Update with More Code:
The Test Class contains:
Product2 plc = new Product2(Name='My Product', ProductCode='PC-1'); insert plc; Id pricebookId = Test.getStandardPricebookId(); PricebookEntry PLCpbe = new PricebookEntry(Product2Id=plc.id, UnitPrice = 200, Pricebook2Id=pricebookid, isActive = True); insert PLCpbe; Order ord = TestDataUtility.addorder('Test Order',ac.id,'Draft',con.id,null); ord.Pricebook2Id = pricebookid;
// This may have been my issue! This pricebookID was different than the one assigned to my Pricebook Entry. I'm getting new errors now, and will continue troubleshooting, but is this likely the issue? insert ord;
In my trigger code, I query for a PricebookEntry by ProductCode. Everything works great when I actually use it in the Test Org. and I'm creating a Test Class now, which is what I'm having an issue with.
The error I get is : INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: 
So I'm hoping somebody can review how I'm setting up a Product, Pricebook, and Pricebook Entry in a Test Class, and setting PBE to an OrderItem in case I'm doing something wrong.
In my Test class, I create a Product
Product2 plc = new Product2(Name='My Product', ProductCode='PC-1'); insert plc;
I get a pricebook ID with
ID PricebookID = Test.getStandardPricebokID();
PricebookEntry PLCpbe = new PricebookEntry(Product2Id=plc.id, UnitPrice = 200, Pricebook2Id=pricebookid, isActive = True); insert PLCpbe;
So, in my actual code, I query for a PricebookEntry by the product code and get a proper ID (not null, that is).
And try to create an OrderItem
OrderItem plcLineItem = New OrderItem(OrderId = o.id, PricebookEntryId = plcpbe.ID, Quantity = 1, UnitPrice = 200);
Like I said, this all works perfectly fine in actuality, but when I run my test class with this test data, I get the following error on upsert* of the OrderItem
INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: 
I've researched this and it seems, to my understanding, that this error means an ID was set to a field incorrectly, as in, it's not the right kind of ID somehow.
- I upsert because in my code, I'm inserting some varying number of OrderItems, and updating others in some cases, so I add them all to a List and upsert all at once at the end.
Can somebody help identify where this error is coming from? I can't think of why an ID would be improper in this case. Let me know if you need any more information - thanks!