public function productPage()

in 3.0.x-and-above/upload/admin/controller/extension/module/facebook_business.php [129:196]


    public function productPage() {
        $data = $this->load->language('extension/module/facebook_business');

        $this->load->model('extension/module/facebook_business');

        // Get Google Product Categories
        $google_taxonomy_url = 'https://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt';

        $curl_options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER         => false,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_AUTOREFERER    => true
        );

        $curl = curl_init($google_taxonomy_url);
        curl_setopt_array($curl, $curl_options);
        $content = curl_exec($curl);

        if (curl_errno($curl)) {
            $curl_error = curl_error($curl);
        } else {
            $curl_error = false;
        }

        curl_close($curl);

        $data['google_product_categories'] = array();
        $data['error_google_product_category'] = '';

        if ($content && !$curl_error) {
            $google_product_categories_file = explode(PHP_EOL, $content);
            $version = array_shift($google_product_categories_file);
            
            foreach ($google_product_categories_file as $google_product_category) {
                if ($google_product_category) {
                    list($id, $name) = explode(' - ', $google_product_category);
                    $data['google_product_categories'][$id] = $name;
                }
            }
        } else {
            $data['error_google_product_category'] = $this->language->get('error_google_product_category');
        }

        if (isset($this->request->get['product_id'])) {
            $facebook_params = $this->model_extension_module_facebook_business->getFacebookParams($this->request->get['product_id']);
        } else {
            $facebook_params = array(
                'facebook_google_product_category' => '',
                'facebook_condition'               => '',
                'facebook_age_group'               => '',
                'facebook_color'                   => '',
                'facebook_gender'                  => '',
                'facebook_material'                => '',
                'facebook_pattern'                 => ''
            );
        }

        foreach ($facebook_params as $facebook_param => $value) {
            if (isset($this->request->post[$facebook_param])) {
                $data[$facebook_param] = $this->request->post[$facebook_param];
            } else {
                $data[$facebook_param] = $value;
            }
        }

        return $data;
    }