2.0.x-2.2.x/upload/catalog/controller/module/facebook_business.php [407:516]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if ($special_info) {
            $product_info = array_merge($product_info, $special_info);
        }

        $formatted_product_details = array(
            'retailer_id'                 => $product_info['product_id'],
            'name'                        => $this->getName($product_info),
            'description'                 => $this->getDescription($product_info),
            'rich_text_description'       => $this->getRichTextDescription($product_info),
            'image_url'                   => $this->formatAndTrimString($this->getImageUrl($product_info['image'])),
            'product_url'                 => $this->getProductUrl($product_info['product_id']),
            'category'                    => $this->getCategory($product_info),
            'brand'                       => $this->getBrand($product_info),
            'price'                       => $this->getPrice($product_info),
            'availability'                => $this->getAvailability($product_info),
            'retailer_product_group_id'   => $product_info['product_id'],
            'additional_image_urls'       => $this->getAdditionalImageUrls($product_info['product_id']),
            'special'                     => $this->getSpecialPrice($product_info),
            'special_period'              => $this->getSpecialPricePeriod($product_info),
            'condition'                   => $this->getCondition($product_info['product_id'])
        );

        $additional_details = $this->getAdditionalDetails($product_info['product_id']);
        $formatted_product_details = array_merge($formatted_product_details, $additional_details);

        // Ensure that the product checks all requirements for the product feed
        if (in_array(false, $formatted_product_details, true) === true) {
            return false;
        } else {
            return $formatted_product_details;
        }
    }

    private function getName($product_info) {
        return $this->formatAndTrimString($product_info['name'], 150);
    }

    private function getDescription($product_info) {
        $description = $this->formatAndTrimString($product_info['description'], 5000);

        // Fallback to Meta Description if description is not available
        if (!$description) {
            $description = $this->formatAndTrimString($product_info['meta_description'], 5000);
        }

        // Fallback to Product Name if Description and Meta Description are not available
        if (!$description) {
            $description = $this->formatAndTrimString($product_info['name'], 5000);
        }

        // If description doesn't contain non-English characters, check if all Uppercase
        if (strlen($description) == strlen(utf8_decode($description))) {
            if (strtoupper($description) == $description) {
                $description = ucfirst(strtolower($description));
            }
        }

        return $description;
    }

    private function getRichTextDescription($product_info) {
        $description = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');

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

        return $description;
    }

    private function getImageUrl($image) {
        // Cater for cases where the image is an external URL
        if (filter_var($image, FILTER_VALIDATE_URL)) {
            return $image;
        } else {
            return $this->getStoreBaseUrl() . 'image/' . $image;
        }
    }

    private function getAdditionalImageUrls($product_id) {
        $formatted_images = '';

        $product_images = $this->model_catalog_product->getProductImages($product_id);

        // Limit of up to 20 images
        $product_images = array_slice($product_images, 0, 20);

        foreach ($product_images as $product_image) {
            $image_url = $this->getImageUrl($product_image['image']);

            // Limit of up to 2000 characters
            if (strlen($formatted_images . $image_url) < 2000) {
                if ($formatted_images) {
                    $formatted_images .= ',' . $image_url;
                } else {
                    $formatted_images .= $image_url;
                }
            } else {
                break;
            }
        }

        return $this->formatAndTrimString($formatted_images);
    }

    private function getProductUrl($product_id) {
        $product_url = $this->url->link('product/product', 'product_id=' . (int)$product_id, true);

        return $this->formatAndTrimString($product_url);
    }

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



2.3.x-and-above/upload/catalog/controller/extension/module/facebook_business.php [407:516]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if ($special_info) {
            $product_info = array_merge($product_info, $special_info);
        }

        $formatted_product_details = array(
            'retailer_id'                 => $product_info['product_id'],
            'name'                        => $this->getName($product_info),
            'description'                 => $this->getDescription($product_info),
            'rich_text_description'       => $this->getRichTextDescription($product_info),
            'image_url'                   => $this->formatAndTrimString($this->getImageUrl($product_info['image'])),
            'product_url'                 => $this->getProductUrl($product_info['product_id']),
            'category'                    => $this->getCategory($product_info),
            'brand'                       => $this->getBrand($product_info),
            'price'                       => $this->getPrice($product_info),
            'availability'                => $this->getAvailability($product_info),
            'retailer_product_group_id'   => $product_info['product_id'],
            'additional_image_urls'       => $this->getAdditionalImageUrls($product_info['product_id']),
            'special'                     => $this->getSpecialPrice($product_info),
            'special_period'              => $this->getSpecialPricePeriod($product_info),
            'condition'                   => $this->getCondition($product_info['product_id'])
        );

        $additional_details = $this->getAdditionalDetails($product_info['product_id']);
        $formatted_product_details = array_merge($formatted_product_details, $additional_details);

        // Ensure that the product checks all requirements for the product feed
        if (in_array(false, $formatted_product_details, true) === true) {
            return false;
        } else {
            return $formatted_product_details;
        }
    }

    private function getName($product_info) {
        return $this->formatAndTrimString($product_info['name'], 150);
    }

    private function getDescription($product_info) {
        $description = $this->formatAndTrimString($product_info['description'], 5000);

        // Fallback to Meta Description if description is not available
        if (!$description) {
            $description = $this->formatAndTrimString($product_info['meta_description'], 5000);
        }

        // Fallback to Product Name if Description and Meta Description are not available
        if (!$description) {
            $description = $this->formatAndTrimString($product_info['name'], 5000);
        }

        // If description doesn't contain non-English characters, check if all Uppercase
        if (strlen($description) == strlen(utf8_decode($description))) {
            if (strtoupper($description) == $description) {
                $description = ucfirst(strtolower($description));
            }
        }

        return $description;
    }

    private function getRichTextDescription($product_info) {
        $description = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');

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

        return $description;
    }

    private function getImageUrl($image) {
        // Cater for cases where the image is an external URL
        if (filter_var($image, FILTER_VALIDATE_URL)) {
            return $image;
        } else {
            return $this->getStoreBaseUrl() . 'image/' . $image;
        }
    }

    private function getAdditionalImageUrls($product_id) {
        $formatted_images = '';

        $product_images = $this->model_catalog_product->getProductImages($product_id);

        // Limit of up to 20 images
        $product_images = array_slice($product_images, 0, 20);

        foreach ($product_images as $product_image) {
            $image_url = $this->getImageUrl($product_image['image']);

            // Limit of up to 2000 characters
            if (strlen($formatted_images . $image_url) < 2000) {
                if ($formatted_images) {
                    $formatted_images .= ',' . $image_url;
                } else {
                    $formatted_images .= $image_url;
                }
            } else {
                break;
            }
        }

        return $this->formatAndTrimString($formatted_images);
    }

    private function getProductUrl($product_id) {
        $product_url = $this->url->link('product/product', 'product_id=' . (int)$product_id, true);

        return $this->formatAndTrimString($product_url);
    }

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



