i want auto generation of meta description for my products liks this: Buy {product name} for Rs {price} at sitename.com | New Book | Authorised seller for {publihser}
1 Answer
Just create an observer on the event catalog_product_save_before
with this code:
public function autoMetaDescription($observer) {
$product = $observer->getEvent()->getProduct();
$metaDescription = "Buy ". $product->getName()." for Rs ".number_format($product->getFinalPrice(), 2)." at sitename.com | New Book | Authorised seller for ". $product->getAttributeText('publisher');
$product->setMetaDescription($metaDescription);
}
Of course you may need some changes if the website is multilanguage. You have to check on which language you are saving the product.
-
-
-
You don't need to edit any file. You need to create one. Check the tutorial I gave you to see how you should create an observer for an event. There is no point in replicating what is there– Marius ♦Commented Oct 21, 2014 at 9:30
-
try this but not working can you tell some detail, i am not understanding tutorial so much for my use because i am new to magneto/programming– DineshCommented Oct 21, 2014 at 12:06