def METHOD_NAME(instance):
    """Delete invalid product channel listings.
    Delete product channel listings for channels for which the deleted variant
    was the last available variant.
    """
    channel_ids = set(
        instance.channel_listings.values_list("channel_id", flat=True)
    )
    product_id = instance.product_id
    variants = (
        models.ProductVariant.objects.filter(product_id=product_id)
        .exclude(id=instance.id)
        .values("id")
    )
    available_channel_ids = set(
        models.ProductVariantChannelListing.objects.filter(
            Exists(
                variants.filter(id=OuterRef("variant_id")),
                channel_id__in=channel_ids,
            )
        ).values_list("channel_id", flat=True)
    )
    not_available_channel_ids = channel_ids - available_channel_ids
    models.ProductChannelListing.objects.filter(
        product_id=product_id, channel_id__in=not_available_channel_ids
    ).delete()