src/Queries/BaseRelationQuery.php
protected function filterByModels($models)
    {
        $values = [];
        foreach ($models as $model) {
            if (($value = $model[$this->foreignKey]) !== null) {
                if (is_array($value)) {
                    $values = array_merge($values, $value);
                } else {
                    $values[] = $value;
                }
            }
        }

        $values = array_filter($values);
        if (empty($values)) {
            $this->stopQuery();
        }

        $primary = $this->localKey;
        if (preg_match('/^PROPERTY_(.*)_VALUE$/', $primary, $matches) && !empty($matches[1])) {
            $primary = 'PROPERTY_' . $matches[1];
        }
        $values = array_unique($values, SORT_REGULAR);
        if (count($values) == 1) {
            $values = current($values);
        } else {
            $this->prepareMultiFilter($primary, $values);
        }

        $this->filter([$primary => $values]);
        $this->select[] = $primary;
    }
protected function filterByModels($models)
    {
        $values = [];
        foreach ($models as $model) {
            if (($value = $model[$this->foreignKey]) !== null) {
                if (is_array($value)) {
                    $values = array_merge($values, $value);
                } else {
                    $values[] = $value;
                }
            }
        }

        $values = array_filter($values);
        if (empty($values)) {
            $this->stopQuery();
        }

        $primary = $this->localKey;
        if (preg_match('/^PROPERTY_(.*)_VALUE$/', $primary, $matches) && !empty($matches[1])) {
            $primary = 'PROPERTY_' . $matches[1];
        }
        $values = array_unique($values, SORT_REGULAR);
        if (count($values) == 1) {
            $values = current($values);
        } else {
            $this->prepareMultiFilter($primary, $values);
        }

        $this->filter([$primary => $values]);
        $this->select[] = $primary;
    }
Добавить фильтр для загрзуки связи относительно моделей
@param Collection|BaseBitrixModel[] $models