I think you're misunderstanding the purpose of the
-i parameter in the Salesforce CLI
In your use case, you can use
-i to identify which field in the
Product2 object the upsert operation will use to determine whether a row of your CSV file will be treated as insert or update. And if update, which record will be updated. In some cases this can be an external ID.
But as you astutely have brought up, external ID has a secondary purpose, which is to perform record matching across relationships and ensure that when a record is inserted the relationship to another object is created.
This is not the purpose of the
While mapping is widely done and understood, it does not appear to be implemented in the Salesforce CLI currently.
For this reason, all header rows field names must match the Salesforce API name of fields in the object. For upsert with relationships and external Ids, you must use the header row of your CSV to indicate the related external ID field that a value corresponds to. Let's say the value you have is stored in
My_Custom_Object__c.External_Id__c. Your CSV might look like this:
Name, MyCustom_Object__r.External_Id__c, Other_Field__c
Product 1, 12345, Rutabega
Product 2, 98765, Beetroot
There are more detailed rules for prepping CSVs in the bulk API developer guide.