config->get('feed_google_sitemap_status')) {
$output = '';
$output .= '';
$this->load->model('catalog/product');
$this->load->model('tool/image');
$this->load->model('localisation/zone');
$products = $this->model_catalog_product->getProducts();
$zones = $this->model_localisation_zone->getZonesByCountryId($this->config->get('config_country_id'));
if (!$zones) {
$zones[] = $this->model_localisation_zone->getZone($this->config->get('config_zone_id'));
}
foreach ($products as $product) {
$product_url = $this->url->link('product/product', 'product_id=' . $product['product_id']);
if (!$this->hasSeoUrl($product_url)) {
continue;
}
foreach ($zones as $zone) {
$output .= '';
$output .= ' ' . $this->escapeUrl($this->model_localisation_zone->getZoneUrlByZone($zone, $product_url)) . '';
$output .= ' weekly';
$output .= ' ' . date('Y-m-d\TH:i:sP', strtotime($product['date_modified'])) . '';
$output .= ' 1.0';
$output .= '';
}
}
$this->load->model('catalog/category');
$output .= $this->getCategories(0);
$this->load->model('catalog/manufacturer');
$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
foreach ($manufacturers as $manufacturer) {
$output .= '';
$output .= ' ' . $this->escapeUrl($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id'])) . '';
$output .= ' weekly';
$output .= ' 0.7';
$output .= '';
}
$this->load->model('catalog/information');
$informations = $this->model_catalog_information->getInformations();
foreach ($informations as $information) {
$output .= '';
$output .= ' ' . $this->escapeUrl($this->url->link('information/information', 'information_id=' . $information['information_id'])) . '';
$output .= ' weekly';
$output .= ' 0.5';
$output .= '';
}
$output .= '';
$this->response->addHeader('Content-Type: application/xml');
$this->response->setOutput($output);
}
}
protected function getCategories($parent_id, $current_path = '') {
$output = '';
$results = $this->model_catalog_category->getCategories($parent_id);
foreach ($results as $result) {
if (!$current_path) {
$new_path = $result['category_id'];
} else {
$new_path = $current_path . '_' . $result['category_id'];
}
$output .= '';
$output .= ' ' . $this->escapeUrl($this->url->link('product/category', 'path=' . $new_path)) . '';
$output .= ' weekly';
$output .= ' 0.7';
$output .= '';
$output .= $this->getCategories($result['category_id'], $new_path);
}
return $output;
}
protected function escapeUrl($url) {
return htmlspecialchars(html_entity_decode($url, ENT_QUOTES, 'UTF-8'), ENT_QUOTES | ENT_XML1, 'UTF-8');
}
protected function hasSeoUrl($url) {
return basename((string)parse_url(str_replace('&', '&', $url), PHP_URL_PATH)) !== 'index.php';
}
}