Hi,
I've got a strange problem. I've got OC 2.2 installed and forced it into https
Everything works fine except the sitemap
When I test it at Google Webmaster Tools I receive an error displaying that the url for images is invalid. This because the base url of my store is missing.
The url in sitemap is: image/cache/catalog/category/product.jpg
instead of : https://www.store.com/image/cache/catal ... roduct.jpg
Does anyone have an idea?
Thanks!
I've got a strange problem. I've got OC 2.2 installed and forced it into https
Everything works fine except the sitemap
When I test it at Google Webmaster Tools I receive an error displaying that the url for images is invalid. This because the base url of my store is missing.
The url in sitemap is: image/cache/catalog/category/product.jpg
instead of : https://www.store.com/image/cache/catal ... roduct.jpg
Does anyone have an idea?
Thanks!
Hi,
When sitemap.xml is accessed from .htaccess file will "redirect" google to feed/google_sitemap
feed/google_sitemap will generate full URL for images
If image URL is generated without BASE URL then:
- config.php is wrong
- or you modified image class directly or from some vqmod/ocmod extension
- many other reasons -
You should ask an developer to take a look
Good Luck!
When sitemap.xml is accessed from .htaccess file will "redirect" google to feed/google_sitemap
Code: Select all
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap
Code: Select all
$output .= '<image:loc>' . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
- config.php is wrong
- or you modified image class directly or from some vqmod/ocmod extension
- many other reasons -
You should ask an developer to take a look
Good Luck!
oc-extensions wrote:Hi,
When sitemap.xml is accessed from .htaccess file will "redirect" google to feed/google_sitemapfeed/google_sitemap will generate full URL for imagesCode: Select all
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap
If image URL is generated without BASE URL then:Code: Select all
$output .= '<image:loc>' . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
- config.php is wrong
- or you modified image class directly or from some vqmod/ocmod extension
- many other reasons -
You should ask an developer to take a look
Good Luck!
Thanks for answering, config.php is correct and I didn't modify image class directly or from some vqmod/ocmod extension.
I think it must be the "many other reasons"
Strangely though, the images are displayed ok in the store.
Hi,
When browser is used on yourstore.com and in page images are loaded like "image/something.png" are displayed correctly (with relative path) because browser convert path to yourstore.com/image/something.php
In your store take a look with view source and check images path (is absolute path or relative path)?
To clarify:
absolute path = "http://www.yourstore.com/image/something.jpg"
relative path = "image/something.jpg"
When browser is used on yourstore.com and in page images are loaded like "image/something.png" are displayed correctly (with relative path) because browser convert path to yourstore.com/image/something.php
In your store take a look with view source and check images path (is absolute path or relative path)?
To clarify:
absolute path = "http://www.yourstore.com/image/something.jpg"
relative path = "image/something.jpg"
oc-extensions wrote:Hi,
When browser is used on yourstore.com and in page images are loaded like "image/something.png" are displayed correctly (with relative path) because browser convert path to yourstore.com/image/something.php
In your store take a look with view source and check images path (is absolute path or relative path)?
To clarify:
absolute path = "http://www.yourstore.com/image/something.jpg"
relative path = "image/something.jpg"
You're right: it's showing the relative path...
Back to the drawing board I guess
oc-extensions wrote:Hi,
When browser is used on yourstore.com and in page images are loaded like "image/something.png" are displayed correctly (with relative path) because browser convert path to yourstore.com/image/something.php
In your store take a look with view source and check images path (is absolute path or relative path)?
To clarify:
absolute path = "http://www.yourstore.com/image/something.jpg"
relative path = "image/something.jpg"
Just a question: do you know of a way to insert the base url temporarely so I can use the sitemap while searching for the error?
Thanks in advance!
Add a function in the controller:
catalog/controller/feed/google_sitemap.php
Then prefix the image url with: $this->serverURL() . 'image/….…...
catalog/controller/feed/google_sitemap.php
Code: Select all
public function serverURL(){
$isSecure = false;
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
$isSecure = true;
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
return ($isSecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'].'/';
}
uksitebuilder wrote:Add a function in the controller
Then prefix the image url with: $this->serverURL() . 'image/….…...Code: Select all
public function serverURL(){ $isSecure = false; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $isSecure = true; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { $isSecure = true; } return ($isSecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'].'/'; }
I will try that, thanks!
what controller file does this go into? I am having the same issueuksitebuilder wrote:Add a function in the controller
Then prefix the image url with: $this->serverURL() . 'image/….…...Code: Select all
public function serverURL(){ $isSecure = false; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $isSecure = true; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { $isSecure = true; } return ($isSecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'].'/'; }
I attempted to put this there but it didnt work. Do i Just copy and paste the code in the very bottom of the file?uksitebuilder wrote:catalog/controller/feed/google_sitemap.php
When i posted the code at the very end me sitemap showed a url but still did not have the full url for the image path. Is there any way to edit how opencart creates the sitemap image urls?
Did you amend the image code in the file
from
'image/….….….….…...
To
$this->serverURL() . 'image/….…...
from
'image/….….….….…...
To
$this->serverURL() . 'image/….…...
can you give me a hand with the code? I havent touched code much outside classic ASP.
Code: Select all
<?php
class ControllerFeedGoogleSitemap extends Controller {
public function index() {
if ($this->config->get('google_sitemap_status')) {
$output = '<?xml version="1.0" encoding="UTF-8"?>';
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
$this->load->model('catalog/product');
$this->load->model('tool/image');
$products = $this->model_catalog_product->getProducts();
foreach ($products as $product) {
if ($product['image']) {
$output .= '<url>';
$output .= '<loc>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<lastmod>' . date('Y-m-d\TH:i:sP', strtotime($product['date_modified'])) . '</lastmod>';
$output .= '<priority>1.0</priority>';
$output .= '<image:image>';
$output .= '<image:loc>' . $this->serverURL() . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
$output .= '<image:caption>' . $product['name'] . '</image:caption>';
$output .= '<image:title>' . $product['name'] . '</image:title>';
$output .= '</image:image>';
$output .= '</url>';
}
}
$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 .= '<url>';
$output .= '<loc>' . $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>0.7</priority>';
$output .= '</url>';
$products = $this->model_catalog_product->getProducts(array('filter_manufacturer_id' => $manufacturer['manufacturer_id']));
foreach ($products as $product) {
$output .= '<url>';
$output .= '<loc>' . $this->url->link('product/product', 'manufacturer_id=' . $manufacturer['manufacturer_id'] . '&product_id=' . $product['product_id']) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>1.0</priority>';
$output .= '</url>';
}
}
$this->load->model('catalog/information');
$informations = $this->model_catalog_information->getInformations();
foreach ($informations as $information) {
$output .= '<url>';
$output .= '<loc>' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>0.5</priority>';
$output .= '</url>';
}
$output .= '</urlset>';
$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 .= '<url>';
$output .= '<loc>' . $this->url->link('product/category', 'path=' . $new_path) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>0.7</priority>';
$output .= '</url>';
$products = $this->model_catalog_product->getProducts(array('filter_category_id' => $result['category_id']));
foreach ($products as $product) {
$output .= '<url>';
$output .= '<loc>' . $this->url->link('product/product', 'path=' . $new_path . '&product_id=' . $product['product_id']) . '</loc>';
$output .= '<changefreq>weekly</changefreq>';
$output .= '<priority>1.0</priority>';
$output .= '</url>';
}
$output .= $this->getCategories($result['category_id'], $new_path);
}
return $output;
}
public function serverURL(){
$isSecure = false;
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
$isSecure = true;
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
return ($isSecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'].'/';
}
}
this is still a nogo. sitemap is still generating the short url and not the long one
here is the sitemap that it gives me. I copied and pasted the new code that was in the box
https://www.uslawnparts.com/test/index. ... le_sitemap
here is the sitemap that it gives me. I copied and pasted the new code that was in the box
https://www.uslawnparts.com/test/index. ... le_sitemap
Last edited by ahill16 on Fri Aug 12, 2016 11:56 am, edited 1 time in total.
I put it in the code above that I amended in your post
Of course you can amend it further by hardcoding your url instead of using the function if you wish
change the above to
Code: Select all
$output .= '<image:loc>' . $this->serverURL() . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
change the above to
Code: Select all
$output .= '<image:loc>http://ENTERYOURDOMAINHERE.COM/' . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
So if i Put this into the code into the file and it still isnt doing anything. Could it be google preventing this. The sitemap generates from opencart right?uksitebuilder wrote:I put it in the code above that I amended in your post
Of course you can amend it further by hardcoding your url instead of using the function if you wishCode: Select all
$output .= '<image:loc>' . $this->serverURL() . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
change the above to
Code: Select all
$output .= '<image:loc>http://ENTERYOURDOMAINHERE.COM/' . $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')) . '</image:loc>';
Most likely you are serving a cached page. Check your caching extensions if you have any that may be caching the file.
Some extensions offer an exclusions list where you can set the feed url to be excluded from caching.
Some extensions offer an exclusions list where you can set the feed url to be excluded from caching.
Are you talking about a cached page in my browser or in my site files?uksitebuilder wrote:Most likely you are serving a cached page. Check your caching extensions if you have any that may be caching the file.
Some extensions offer an exclusions list where you can set the feed url to be excluded from caching.
Who is online
Users browsing this forum: No registered users and 36 guests