You can use the following code as an example of a trigger that will update a list of Product Codes from Opportunity Products to a target text field on the Opportunity

trigger OppProductSummarizer on OpportunityLineItem (after delete, after insert, after update) {

  Set OppIds = new Set();
  List OppsForUpdate = new List();
  List OLI= new List();
  Integer i;
  
  /////NOTE: YOU SHOULD DO A RECURSION CHECK HERE WITH A STATIC CLASS TO MAKE SURE THIS TRIGGER ONLY RUNS ONCE 
  //SEE HERE FOR MORE INFO: https://help.salesforce.com/articleView?id=000133752&type=1  
  //YOU SHOULD ALSO ADD A CUSTOM SETTING TO TURN THIS TRIGGER ON OR OFF
  //IF YOU ARE SERIOUSLY INTERESTED IN USING THIS CODE BUT ARE CONFUSED, CONTACT info@magicrobot.com 
  
  if (Trigger.isDelete) {
    for (OpportunityLineItem a : trigger.old) {
      OppIds.add(a.Opportunity);
    }
  } else {
    for (i = 0; i < Trigger.new.size(); i++) {
 		for (OpportunityLineItem a : trigger.new) {
          OppIds.add(a.Opportunity);
        }
    }
  }
  System.debug(LoggingLevel.Info,'This is debug: ' + OppIds);
  Map<Id, List> OpportunityLineItems = new Map<Id, List>();
  List tmplst = new List();
  Id LastId = null;
  if (OppIds.size() > 0) {
    //replace the below "ProductCode" with the API Name of the field you want strung together
    for (OpportunityLineItem a : [select Id, Product2.ProductCode, Opportunity from OpportunityLineItem where Opportunity IN : OppIds order by Opportunity]) {
      if (LastId == null || LastId != a.Opportunity) {
        if (LastId != null) {
          OpportunityLineItems.put(LastId, tmplst);
        }
        tmplst = new List();
      }
      tmplst.add(a);
      LastId = a.Opportunity;
    }
    OpportunityLineItems.put(LastId, tmplst);
    for (Opportunity p : [select Id from Opportunity where Id IN : OppIds]) {
      if (OpportunityLineItems.size() > 0) {
       OLI= OpportunityLineItems.get(p.Id);
      }
      System.debug(LoggingLevel.Info,'This is debug: ' + Ast);
      String SumProduct = '';
      if (Ast != null) {
        Set ProductCodeSet = new Set();

        System.debug(LoggingLevel.Info,'This is debug: ' + Ast[0].Product2);

        for (OpportunityLineItem a : Ast) {
          if (a.Product2.ProductCode != null) {
            ProductCodeSet.add(a.Product2.ProductCode);
          }
        }


        for (String s : ProductCodeSet) {
          SumProduct += s + ';';
        }

        if (SumProduct.length() > 255) {
          SumProduct = SumProduct.substring(0, 255);
        }

      }
      ////replace the below "OpportunityLineItems_ProductCodes__c" with whatever target field you have on the Opportunity
      p.OpportunityLineItems_ProductCodes__c = SumProduct;

      OppsForUpdate.add(p);

    }
  }
  if (OppsForUpdate.size() > 0) {
    update OppsForUpdate;
  }

}