Auto generate meta description for all products on Reindex data like this :Buy {product name} for Rs {price} at sitename.com | New Book | Authorised seller for {publihser}
-
There is no need to do this every time you reindex. Instead you can do this on product save. Listen for the product save before event and set the meta data then. In this way things will be more efficient.– Henry's CatCommented Oct 29, 2014 at 11:17
-
@Woolfie i create a module on catalog_product_save_before this working when save product but not working for imported product– DineshCommented Oct 29, 2014 at 11:20
-
Sounds like you are on the right track. How are you importing products?– Henry's CatCommented Oct 29, 2014 at 11:21
-
@Woolfie using external extension instead of magneto's default import– DineshCommented Oct 29, 2014 at 11:23
-
In that case you could write a module with a cron job that runs once in a while. This could them check the most recent product id, if new ones have arrived do the update as desired. You could store the last product id or do a query to find products created since last check.– Henry's CatCommented Oct 29, 2014 at 11:25
|
Show 2 more comments
1 Answer
It's easier to observe the catalog_product_save_after
event. It's triggered after saving the product.
The observer would look something like
class [Namespace]_[Module]_Model_Observer
{
public function saveInventoryData($observer)
{
$product = $observer->getEvent()->getProduct();
$product->setMetaDescription(":Buy {$product->getName()} for Rs {$product->getPrice()} at sitename.com | New Book | Authorised seller for {$product->getPublisher()}");
$product->save();
return $this;
}
}