getCountryIds example

private function addCondition(HasAddressWithCountryCondition $condition, QueryBuilder $query): void
    {
        $query->innerJoin(
            'customer',
            's_user_addresses',
            'addresses',
            'addresses.user_id = customer.id AND addresses.country_id IN (:HasAddressWithCountryCondition)'
        );
        $query->addGroupBy('customer.id');

        $query->setParameter(':HasAddressWithCountryCondition', $condition->getCountryIds(), Connection::PARAM_INT_ARRAY);
    }
}
return $condition instanceof HasNoAddressWithCountryCondition;
    }

    public function handle(ConditionInterface $condition, QueryBuilder $query): void
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(HasNoAddressWithCountryCondition $condition, QueryBuilder $query): void
    {
        $ors = [];
        foreach ($condition->getCountryIds() as $i => $number) {
            $ors[] = 'country_id = :HasNoAddressWithCountryCondition' . $i;
        }
        $query->innerJoin(
            'customer',
            's_user_addresses',
            'addresses',
            'addresses.user_id = customer.id AND addresses.user_id NOT IN ( SELECT user_id FROM s_user_addresses WHERE (' . implode(' OR ', $ors) . ') )'
private Connection $connection;

    public function __construct(CountryGatewayInterface $gateway, Connection $connection)
    {
        $this->gateway = $gateway;
        $this->connection = $connection;
    }

    public function getCountries(ShopContextInterface $context)
    {
        $ids = $this->getCountryIds();
        $countries = $this->gateway->getCountries($ids$context);

        $states = $this->gateway->getCountryStates($ids$context);

        $result = [];
        foreach ($countries as $country) {
            if (!$country->isActive()) {
                continue;
            }

            if (isset($states[$country->getId()])) {
                
Home | Imprint | This part of the site doesn't use cookies.