How can I make a dynamic canonical tag on Magento

We generally recommend to hide internal site search from getting indexed

/app/design/frontend/{your_package}/{your_theme}/template/page/html/head.phtml

Add this code:

<?php
// code for show canonical tag on all page
$current_url = Mage::helper('core/url')->getCurrentUrl();
if(!empty($current_url))
{
$url2 = substr($current_url, 0, strpos($current_url, '?'));
if(!empty($url2)) {
?>
<link rel="canonical" href="<?php echo $url2; ?>" />
<?php } else { ?>
<link rel="canonical" href="<?php echo $current_url; ?>" />
<?php } } ?>

Breadcrumbs for Product page

Add additional breadcrumbs links to Product Page.
If customers go to product page via current url-link, via browser or via search (Google, Yahoo), or search in Magento – customer will see short breadcrumbs. Like “Home->Product Name”. This normal.
But in Search systems (like Google) – will not show breadcrumbs for product page.

The module Breadcrumbs for Product page – will help with breadcrumbs for Product. Now in Google search result will show breadcrumbs for Product, of course if product has categories and not blocked it 🙂 .
So, with extension Breadcrumbs for Product page – will breadcrumbs like “Home->Category1->Category2->Product Name”

We got this blog from www.magentocommerce.com for blog more information Click Here

How to generate a sitemap.xml with image in Magento

This is good for SEO if product images include in the sitemap.xml file. We have implemented to add images URL in Magento sitemap.xml file.

file path : app/code/core/Mage/Sitemap/Model/Sitemap.php

Replace this code with existing code.

/**
* Generate products sitemap
*/
$changefreq = (string)Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
$priority = (string)Mage::getStoreConfig('sitemap/product/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
$products = new Varien_Object();
$products->setItems($collection);
Mage::dispatchEvent('sitemap_products_generating_before', array(
'collection' => $products
));
foreach ($products->getItems() as $item) {
$image = Mage::getModel('catalog/product')->load($item->getId())->image;
$img = Mage::getModel('catalog/product')->load($item->getId())->getImageUrl();
$xml = sprintf(
'<url><loc>%s</loc><image:image><image:loc>%s</image:loc></image:image><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
htmlspecialchars($baseUrl . $item->getUrl()),
htmlspecialchars($baseUrl."media/catalog/product" . $image),
$date,
$changefreq,
$priority
);
$io->streamWrite($xml);
}
unset($collection);

Magento url key has strange numbers added by the system Magento

Step 1

Make sure the URL you’re trying to achieve is in fact unique.

There is a reason Magento appends these numbers to the end of your URLs, because it actually already exists. It’s like creating two categories with the same name in WordPress, the second category will have the URL “/category-2/”.

Step 2 Do a database backup

Open up PHPMyAdmin or something similar.

Find the Core_url_rewrite table.

Search for your url in the request path. In my example I typed: ‘hats%’ this will find anything beginning with hats in the url.

Step 3

Just remember if you hard linked this page it will now 404. So if there is a risk of this, make sure you create a new redirect after this for that page.

Delete all rows from the search results.

Step 4

Reindex your Catalog URL rewrites.

Step 5

Go back to the category or product and click save.

Your urls should now be as desired!

The upgrade will help with the underlying cause of this, but will not correct it. You will still need to run through this process regardless.

CreareSEO good extension for magento SEO

Creare SEO for Magento includes the following features:

  • HTML sitemap
  • Unique category headings
  • Noindex on category filters
  • Default meta descriptions and page titles for products and categories
  • 301 redirects for discontinued products
  • Config-editable .htaccess and robots.txt
  • Ability to disable keywords and meta description tags
  • Twitter cards for product pages
  • Performance cleanup script
  • An SEO checking page in the admin
  • Duplicate product button removal
  • Breadcrumbs structured data
  • XML sitemap fix
  • Canonical product redirect
  • Universal Anayltics Support
  • Mandatory Product Image Labels
  • Google Sitelinks Search Support
  • Product Structured Data
  • Social Media Schema
  • Google Content Grouping
  • Google Tag Manager Support
  • Logo & Organization structured data
  • Canonical links for CMS pages

We got this blog from magentocommerce.com for blog more information Click Here