public function genFeed()

in 2.3.x-and-above/upload/catalog/controller/extension/module/facebook_business.php [14:61]


    public function genFeed($gen_now = false) {
        $this->load->model('catalog/product');
        $this->load->model('extension/module/facebook_business');
        $this->load->model('localisation/currency');

        $start_time = time();

        try {
            $product_feed_path = $this->getProductFeedPath();

            if ($product_feed_path) {
                $is_stale = $this->isFeedFileStale($product_feed_path);

                if ($is_stale || $gen_now) {
                    // Remove any existing file
                    if (is_file($product_feed_path)) {
                        unlink($product_feed_path);
                    }

                    if (!$this->generateProductFeedFile($product_feed_path)) {
                        return false;
                    }

                    // Perform one last check if the feed file is successfully generated
                    if (!is_file($product_feed_path)) {
                        return false;
                    }
                }
            } else {
                return false;
            }

            $end_time = time();
            $feed_gen_time = $end_time - $start_time;
        
            $this->estimateFeedGenerationTimeWithDecay($feed_gen_time);
      
            // genFeedPing return time estimation only
            if (isset($this->request->get['from']) && $this->request->get['from'] == 'genFeedPing') {
                return;
            }
      
            $this->sendFileResponse($product_feed_path);
        } catch (Exception $e) {
            $this->response->addHeader('Content-type: text');
            $this->response->setOutput('There was a problem generating your feed: %s', $e->getMessage());
        }
    }