public function handle(QueryInterface $query)
    {
        $lastCangedTime = $this->getChangedDateTime();
        $currentDateTime = $this->getCurrentDateTime();

        $stocks = $this->client->getIterator('stockmanagement/stock', [
            'updatedAtFrom' => $lastCangedTime->format(DATE_W3C),
            'updatedAtTo' => $currentDateTime->format(DATE_W3C),
            'columns' => ['variationId'],
        ]);

        $this->outputHandler->startProgressBar(count($stocks));

        foreach ($this->getAffectedVariations($stocks) as $variationIdentifierGroup) {
            if (empty($variationIdentifierGroup)) {
                continue;
            }

            $elements = $this->client->getIterator('items/variations', [
                'with' => 'stock',
                'id' => implode(',', $variationIdentifierGroup),
            ]);

            foreach ($elements as $element) {
                $stock = null;

                try {
                    $stock = $this->responseParser->parse($element);
                } catch (Exception $exception) {
                    $this->logger->error($exception->getMessage());
                }

                if ($stock !== null) {
                    yield $stock;
                }

                $this->outputHandler->advanceProgressBar();
            }
        }

        $this->outputHandler->finishProgressBar();
        $this->setChangedDateTime($currentDateTime);
    }
public function handle(QueryInterface $query)
    {
        $lastCangedTime = $this->getChangedDateTime();
        $currentDateTime = $this->getCurrentDateTime();

        $stocks = $this->client->getIterator('stockmanagement/stock', [
            'updatedAtFrom' => $lastCangedTime->format(DATE_W3C),
            'updatedAtTo' => $currentDateTime->format(DATE_W3C),
            'columns' => ['variationId'],
        ]);

        $this->outputHandler->startProgressBar(count($stocks));

        foreach ($this->getAffectedVariations($stocks) as $variationIdentifierGroup) {
            if (empty($variationIdentifierGroup)) {
                continue;
            }

            $elements = $this->client->getIterator('items/variations', [
                'with' => 'stock',
                'id' => implode(',', $variationIdentifierGroup),
            ]);

            foreach ($elements as $element) {
                $stock = null;

                try {
                    $stock = $this->responseParser->parse($element);
                } catch (Exception $exception) {
                    $this->logger->error($exception->getMessage());
                }

                if ($stock !== null) {
                    yield $stock;
                }

                $this->outputHandler->advanceProgressBar();
            }
        }

        $this->outputHandler->finishProgressBar();
        $this->setChangedDateTime($currentDateTime);
    }
{@inheritdoc}