2.0.x-2.2.x/upload/catalog/controller/module/facebook_business.php [331:404]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            if (isset($products) && sizeof($products) > 0) {
                if (!$this->writeProductFeedFile($products, $feed_file)) {
                    fclose($feed_file);
                    return false;
                }
            }
        }

        // Feed file generation is successful
        fclose($feed_file);
        return true;
    }

    private function writeProductFeedFile($products, $feed_file) {
        $product_data = array();

        try {
            foreach ($products as $product) {
                $formatted_product_data = $this->formatProductDetails($product);

                if ($formatted_product_data) {
                    fwrite($feed_file, $this->convertProductDataAsFeedRow($formatted_product_data));
                }
            }

            return true;
        } catch (Exception $e) {
            return false;
        }
    }

    private function convertProductDataAsFeedRow($product_data) {
        $row = '';

        $count = count($product_data);

        foreach ($product_data as $product) {
            $count--;

            if ($count == 0) {
                $row .= $product . PHP_EOL;
            } else {
                $row .= $product . ',';
            }
        }

        return $row;
    }

    private function formatAndTrimString($text, $length = false) {
        if ($text) {
            $text = trim(strip_tags(html_entity_decode(html_entity_decode($text), ENT_QUOTES | ENT_COMPAT, 'UTF-8')));

            if ($length && strlen($text) > $length) {
                $text = substr($text, 0, $length);
            }

            $text = '"' . str_replace('"', '""', $text) . '"';

            return $text;
        } else {
            return '""';
        }
    }

    private function getStoreBaseUrl() {
        if ($this->config->get('config_ssl')) {
            return HTTP_SERVER;
        } else {
            return HTTPS_SERVER;
        }
    }

    private function formatProductDetails($product_info) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



3.0.x-and-above/upload/catalog/controller/extension/module/facebook_business.php [333:406]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            if (isset($products) && sizeof($products) > 0) {
                if (!$this->writeProductFeedFile($products, $feed_file)) {
                    fclose($feed_file);
                    return false;
                }
            }
        }

        // Feed file generation is successful
        fclose($feed_file);
        return true;
    }

    private function writeProductFeedFile($products, $feed_file) {
        $product_data = array();

        try {
            foreach ($products as $product) {
                $formatted_product_data = $this->formatProductDetails($product);

                if ($formatted_product_data) {
                    fwrite($feed_file, $this->convertProductDataAsFeedRow($formatted_product_data));
                }
            }

            return true;
        } catch (Exception $e) {
            return false;
        }
    }

    private function convertProductDataAsFeedRow($product_data) {
        $row = '';

        $count = count($product_data);

        foreach ($product_data as $product) {
            $count--;

            if ($count == 0) {
                $row .= $product . PHP_EOL;
            } else {
                $row .= $product . ',';
            }
        }

        return $row;
    }

    private function formatAndTrimString($text, $length = false) {
        if ($text) {
            $text = trim(strip_tags(html_entity_decode(html_entity_decode($text), ENT_QUOTES | ENT_COMPAT, 'UTF-8')));

            if ($length && strlen($text) > $length) {
                $text = substr($text, 0, $length);
            }

            $text = '"' . str_replace('"', '""', $text) . '"';

            return $text;
        } else {
            return '""';
        }
    }

    private function getStoreBaseUrl() {
        if ($this->config->get('config_ssl')) {
            return HTTP_SERVER;
        } else {
            return HTTPS_SERVER;
        }
    }

    private function formatProductDetails($product_info) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



