def METHOD_NAME(self, raw, upload_type):
    # Check that the search matches some products
    ids = set(UPC_SET_REGEX.findall(raw))
    # switch for included or excluded products
    if upload_type == RangeProductFileUpload.EXCLUDED_PRODUCTS_TYPE:
        products = self.product_range.excluded_products.all()
        action = _("excluded from this range")
    else:
        products = self.product_range.all_products()
        action = _("added to this range")
    existing_skus = set(
        products.values_list("stockrecords__partner_sku", flat=True)
    )
    existing_upcs = set(products.values_list("upc", flat=True))
    existing_ids = existing_skus.union(existing_upcs)
    new_ids = ids - existing_ids
    if len(new_ids) == 0:
        self.add_error(
            "query",
            _(
                "The products with SKUs or UPCs matching %(skus)s have "
                "already been %(action)s"
            )
            % {"skus": ", ".join(ids), "action": action},
        )
    else:
        self.products = Product._default_manager.filter(
            Q(stockrecords__partner_sku__in=new_ids) | Q(upc__in=new_ids)
        )
        if len(self.products) == 0:
            self.add_error(
                "query",
                _("No products exist with a SKU or UPC matching %s")
                % ", ".join(ids),
            )
        found_skus = set(
            self.products.values_list("stockrecords__partner_sku", flat=True)
        )
        found_upcs = set(self.products.values_list("upc", flat=True))
        found_ids = found_skus.union(found_upcs)
        self.missing_skus = new_ids - found_ids
        self.duplicate_skus = existing_ids.intersection(ids)