Archive for the ‘Magento’ Category

Magento Indexes

leave a comment »

Magento stores a lot of its data (related to category, products, urls, search, discounts, promotion rules etc)  in index tables. This is required to make the queries run faster and hence faster page load. But this also means that  any changes that we make on the system do not get reflected immediately. For example, if you add new products or categories, their urls do not become active unless the indexes are run.

So what are the different type of indexes that are created?

You can find this by running this command “php /your-magento-path/shell/indexer.php info

And here is what you will find:

catalog_product_attribute Product Attributes
catalog_product_price Product Prices
catalog_url Catalog URL Rewrites
catalog_product_flat Product Flat Data
catalog_category_flat Category Flat Data
catalog_category_product Category Products
tag_summary Tag Aggregation Data
cataloginventory_stock Stock Status
catalogsearch_fulltext Catalog Search Index

So one needs to be careful and run the appropriate index for making sure the changes done to the system (addition/deletion of data) are reflected.

To run the index, you simply have to do this:

php /your-magento-path/shell/indexer.php –reindex catalog_product_price

You can also find the status of your index – running/pending

php /your-magento-path/shell/indexer.php –status



Written by rationalspace

February 18, 2013 at 1:59 pm

Posted in Magento

Tagged with ,

How to get rid of “index.php” in urls (Magento)?

leave a comment »

Magento by default appends index.php in all urls.  Though this does not affect any functionality but these kind of urls are not neat and also less effective from SEO’s perspective as index.php doesn’t not mean much to a search engine.

Therefore, often it is desirable to get rid of it and have a clean url in its place.

One can achieve this by simply issuing a redirect directive in your ngninx/apache config file.


location / {
try_files $uri $uri/ @handler;
location @handler { ## Magento uses a common front handler
rewrite / /index.php;


In .htaccess of the store add:
RewriteRule .* index.php [L]

In main apache config add:
AllowOverride all

A similar directive is required for all the web-stores that one may have. Also you need to make sure that your apache rewrite module is enabled and after making changes you restart the server and test.

Written by rationalspace

February 14, 2013 at 1:17 pm

Posted in Magento, SEO

Tagged with , ,

How to customize page title and description in Magento categories or products

leave a comment »

With a store having products of the order of 1000 or above, it becomes very difficult to maintain titles and description in each category and product. One option would be to fill in this data programmatically for each category and then load it. Still it becomes difficult to keep changing this on regular basis and hence maintenance becomes a challenge.

A smarter solution would be if one could come up with a generic title and description with keywords as placeholders that can be filled dynamically on page load.  So for example, if you have 3 different keywords that work well for your page, you can have the description with “buy< keyword1> at yourwebsite.com, the best  place to shop <keyword2> online. We offer the widest collection of <keyword3> at best prices”

How to  achieve this?

  • You could store this title & description in core_config_data. For example for categories, look for “category_default_title” in this table and update the value to your generic text. “buy< keyword1> at yourwebsite.com, the best  place to shop <keyword2> online. We offer the widest collection of <keyword3> at best prices”
  • Now in category table , update the attribute “Meta Keywords” with keyword1, keyword2, keyword3

require_once ‘../app/Mage.php’;
$category = Mage::getModel ( ‘catalog/category’ );
$tree = $category->getTreeModel ();
$tree->load ();
$ids = $tree->getCollection ()->getAllIds ();

$keywords = “keyword1,keyword2,keyword3”;
foreach ( $ids as $id ) {
$_category = $category->load($id);

  • Modify getSeoTitle function in  “app/code/local/Mage/Catalog/Model/Category.php” to get the keywords from category and replace them in core_config_data “catalog/seo/category_default_title”

$seoKeyword = $this->getMetaKeywords();
$array = explode(“,”,$seoKeyword);
$_seoDefaultTitle = Mage::getStoreConfig(‘catalog/seo/category_default_title’);
$seoTitle= str_replace(“%KEYWORD1%”,$array[0], $_seoDefaultTitle);
$seoTitle= str_replace(“%KEYWORD2%”,$array[1], $seoTitle);

Written by rationalspace

February 13, 2013 at 9:37 am

Posted in Magento, SEO

Tagged with , ,

%d bloggers like this: