2

I have a multi language store in magento 1.8ce

Meta title Same as The title of The product

Meta desciption I use a combination of The title, sku and description (with The html tags)

Meta keywords The description with The html tags

How can this be automated? And The html tags being striped from The description? And also automatically use The description and title from The right language store.

  • 1
    I am currently working on an extension that makes it easy to generate attribute values from other attributes. It's not perfect yet but except from stripping the HTML it already can do what you need out of the box. HTML stripping can be added with a simple custom generator. Take a look if you can use it: github.com/magento-hackathon/DerivedAttributes – Fabian Schmengler Jul 24 '15 at 9:45
  • I just noticed that there is no documentation yet except for the installation. You will find a menu "Derived Attributes" under Catalog > Attributes. Add a new rule with the "always" condition and the "template" generator. Use "#title# #sku# #description #" as template for the meta description attribute. Then click apply rules to set the attribute for all existing products. From then on it will be automatically set on save. If you are interested, I'll add instructions how to implement the HTML stripping. – Fabian Schmengler Jul 24 '15 at 9:53
  • Cross-post – unor Jul 24 '15 at 11:13
2

You can modify the default Magento page meta tags by customising the phtml in the head.phtml file of your theme at

app/design/frontend/YOURTHEME/default/template/page/html/head.phtml

For example to modify the meta description for a product you could do something like :

<?php
$_metaDescription='';
if (Mage::registry('current_product'))
{
  // auto generate meta description
if (strip_tags(Mage::registry('current_product')->getDescription())=="")
{
    $_metaDescription=htmlspecialchars($this->getDescription());
} else {
      $_metaDescription=strip_tags(Mage::registry('current_product')->getDescription());
}
} else {
     $_metaDescription=htmlspecialchars($this->getDescription());
}
?>
<meta name="description" content="<?php echo $_metaDescription ?>" />

This example checks that the current frontend view is a product, and if a product (long) description exists strips the tags from the description text and sets the meta description to this text.

You can modify this further to include product name, sku etc.

Note the description should optimally be between 150-160 characters, so you should check the output of your meta description to see if it is meaningful and within these limits.

I would advise against adding the description text to the meta keywords field. Google pretty much ignores the meta keywords content these days, and if you want to try and use this for SEO keywords then a single relevant keyword or search phrase will have more SEO significance than the product description text.

More information regarding modifying the meta content can be found here

http://blog.gaiterjones.com/magento-seo-generate-meta-description-tags-automatically/

  • Great, there is only one ) to much if (strip_tags(Mage::registry('current_product')->getDescription()))=="") should be if (strip_tags(Mage::registry('current_product')->getDescription())=="") – Ronny Jul 27 '15 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.