getChangeSets example

->addListener(PreWriteValidationEvent::classfunction DPreWriteValidationEvent $event): void {
                foreach ($event->getCommands() as $command) {
                    if (!$command instanceof ChangeSetAware) {
                        continue;
                    }
                    $command->requestChangeSet();
                }
            });

        $result = $this->productRepository->update($updates, Context::createDefaultContext());

        $changeSets = $this->getChangeSets(ProductDefinition::ENTITY_NAME, $result, 2);
        $changeSetForProduct1 = array_values(array_filter($changeSetsfunction DChangeSet $changeSet) use (&$productId1) {
            return $changeSet->getBefore('id') === hex2bin($productId1);
        }))[0];
        $changeSetForProduct2 = array_values(array_filter($changeSetsfunction DChangeSet $changeSet) use (&$productId2) {
            return $changeSet->getBefore('id') === hex2bin($productId2);
        }))[0];

        static::assertNotNull($changeSetForProduct1);
        static::assertTrue($changeSetForProduct1->hasChanged('stock'));
        static::assertEquals(1, $changeSetForProduct1->getBefore('stock'));
        static::assertEquals(100, $changeSetForProduct1->getAfter('stock'));

        
Home | Imprint | This part of the site doesn't use cookies.