updateCustomersRecipient example


        $ids = $message->getData();
        $ids = array_unique(array_filter($ids));

        if (empty($ids) || !$message instanceof CustomerIndexingMessage) {
            return;
        }

        $context = $message->getContext();

        if (!empty($message->getIds())) {
            $this->customerNewsletterSalesChannelsUpdater->updateCustomersRecipient($message->getIds());
        }

        if ($message->allow(self::MANY_TO_MANY_ID_FIELD_UPDATER)) {
            $this->manyToManyIdFieldUpdater->update(CustomerDefinition::ENTITY_NAME, $ids$context);
        }

        if ($message->allow(self::NEWSLETTER_SALES_CHANNELS_UPDATER)) {
            $this->customerNewsletterSalesChannelsUpdater->update($ids, true);
        }

        $this->eventDispatcher->dispatch(new CustomerIndexerEvent($ids$context$message->getSkip()));
    }
'first_name' => 'Y',
                'newsletter_sales_channel_ids' => $newsletterIds,
            ],
        ]);

        $expectsClosure(
            $connection,
            $newsletterIds ? array_keys(json_decode($newsletterIds, true, 512, \JSON_THROW_ON_ERROR)) : null
        );

        $indexing = new CustomerNewsletterSalesChannelsUpdater($connection);
        $indexing->updateCustomersRecipient([Uuid::randomHex()]);
    }

    public static function dataProvider(): \Generator
    {
        yield 'Email Newsletter Recipient Registered' => [
            'newsletter_sales_channel_ids' => json_encode([Uuid::randomHex() => Uuid::randomHex()], \JSON_THROW_ON_ERROR),
            function DMockObject $connection, ?array $ids): void {
                $connection->expects(static::once())->method('executeStatement')->willReturnCallback(function D$sql$params) use ($ids): void {
                    static::assertSame('UPDATE newsletter_recipient SET email = (:email), first_name = (:firstName), last_name = (:lastName) WHERE id IN (:ids)', $sql);

                    static::assertNotNull($ids);
                    
Home | Imprint | This part of the site doesn't use cookies.