public function generateProductRequestData()

in Model/Product/Feed/Method/BatchApi.php [78:131]


    public function generateProductRequestData($accessToken = null)
    {
        $currentBatch = 1;
        $requests = [];
        $responses = [];
        $exceptions = 0;
        foreach ($this->productRetrievers as $productRetriever) {
            $offset = 0;
            $limit = $productRetriever->getLimit();
            do {
                $products = $productRetriever->retrieve($offset);
                $offset += $limit;
                if (empty($products)) {
                    break;
                }

                foreach ($products as $product) {
                    try {
                        $requests[] = $this->buildProductRequest($product);
                    } catch (\Exception $e) {
                        $exceptions++;
                        // Don't overload the logs, log the first 3 exceptions
                        if ($exceptions <= 3) {
                            $this->fbeHelper->logException($e);
                        }
                        // If it looks like a systemic failure : stop feed generation
                        if ($exceptions > 100) {
                            throw $e;
                        }
                    }

                    if (count($requests) === self::BATCH_MAX) {
                        $this->fbeHelper->log(
                            sprintf('Pushing batch %d with %d products', $currentBatch, count($requests))
                        );
                        $response = $this->fbeHelper->makeHttpRequest($requests, $accessToken);
                        $this->fbeHelper->log('Product push response ' . json_encode($response));
                        $responses[] = $response;
                        unset($requests);
                        $currentBatch++;
                    }
                }
            } while (true);
        }

        if (!empty($requests)) {
            $this->fbeHelper->log(sprintf('Pushing batch %d with %d products', $currentBatch, count($requests)));
            $response = $this->fbeHelper->makeHttpRequest($requests, $accessToken);
            $this->fbeHelper->log('Product push response ' . json_encode($response));
            $responses[] = $response;
        }

        return $responses;
    }