Post by adwordsvouchersshop » Mon Jul 30, 2012 3:14 am

My opencart sitemap is located on: index.php?route=feed/google_sitemap.
And the file that controls this is located in catalog/controller/feed/google_sitemap.php.
The thing is that i wish to remove 2 information pages, i don't want to remove all the information pages.
I believe that this is the piece of code:

Code: Select all

$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>hourly</changefreq>';
			$output .= '<priority>1.0</priority>';
			$output .= '</url>';   
		 }
		 
		 $output .= '</urlset>';
		 
		 $this->response->addHeader('Content-Type: application/xml');
		 $this->response->setOutput($output);
that need to be modified. How can i add 2 urls on exception?

2. How can i add into this file the index.php or domain url?

New member

Posts

Joined
Fri Mar 11, 2011 7:00 am

Post by adwordsvouchersshop » Mon Jul 30, 2012 5:02 pm

Sorry for the bump, but this is quite important. The 2 urls that i don't want to see in the sitemap are terms and conditions and privacy policy, afraid of duplicate content. The fact is that i have blocked them via robots.txt, but webmaster tools shows 2 errors on the sitemap, of course warning be about this fact, that i have blocked them. Second thing also important i did not see any url in this sitemap matching the index.php.

New member

Posts

Joined
Fri Mar 11, 2011 7:00 am

Post by dolrichfortich » Mon Jul 30, 2012 6:04 pm

Try this one.

Code: Select all

		$this->load->model('catalog/information');

		$informations = $this->model_catalog_information->getInformations();

		//Add the information ids you want to skip
		//Ex: http://example.com/index.php?route=information/information&information_id=3
		//Information id is 3

		$skip_informations = array(3);

		foreach ($informations as $information) {
			
			if(in_array($information['information_id'], $skip_informations)) {
				continue;
			}

			$output .= '<url>';
			$output .= '<loc>' . $this->url->link('information/information', 'information_id=' . $information['information_id']) . '</loc>';
			$output .= '<changefreq>hourly</changefreq>';
			$output .= '<priority>1.0</priority>';
			$output .= '</url>';
		}

		$output .= '</urlset>';

		$this->response->addHeader('Content-Type: application/xml');
		$this->response->setOutput($output);

Opencart Options Pro, Reward Points For Review, DISQUS Comment Form,
Dolrich Fortich - Freelance web developer

Image


User avatar
New member

Posts

Joined
Thu Aug 05, 2010 8:09 pm
Location - Philippines

Post by adwordsvouchersshop » Mon Jul 30, 2012 6:37 pm

Working like a charm dolrichfortich, and if you have multiple urls you just need to add on this line
$skip_informations = array(3, 4, 5); with comma all the id's you want. Thanks a lot, too bad opencart forum doesn't have a thank you button.

New member

Posts

Joined
Fri Mar 11, 2011 7:00 am

Post by dolrichfortich » Tue Jul 31, 2012 12:37 am

Yup, thats right. Glad I could help.

Opencart Options Pro, Reward Points For Review, DISQUS Comment Form,
Dolrich Fortich - Freelance web developer

Image


User avatar
New member

Posts

Joined
Thu Aug 05, 2010 8:09 pm
Location - Philippines

Post by adwordsvouchersshop » Tue Jul 31, 2012 9:21 pm

dolrichfortich wrote:Yup, thats right. Glad I could help.
One more thing. I forgot about the index: http://www.domain.com. How do i add this?

New member

Posts

Joined
Fri Mar 11, 2011 7:00 am

Post by adwordsvouchersshop » Wed Aug 01, 2012 11:58 pm

Managed to figure it out:
Added:

Code: Select all

              $output .= '<url>';  
              $output .= '<loc>' . $this->url->link('common/home') . '</loc>';
              $output .= '<changefreq>hourly</changefreq>';
	      $output .= '<priority>1.0</priority>';
	      $output .= '</url>';   
after:

Code: Select all

$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

New member

Posts

Joined
Fri Mar 11, 2011 7:00 am
Who is online

Users browsing this forum: Bing [Bot] and 41 guests