We currently have meta data set up in the individual products. However, I would create an automated meta description for all products (including backdating old products).
I know I could do this through import/export – but I want something that is automated going forward.
For example, my product meta description should be '[brand], [product-name], buy online today.'
I can find how to do this for opengraph meta content but not meta descriptions and key words.
Can anyone please assist?
Best Answer
In this case, you can use event/observer.
Fire an observer on the event
catalog_product_load_after
at frontend area set meta description on the fly.events.xml code
ProductLoadAfter.php code
Some notes:
Assume that brand is text type attribute. If the brand is an attribute of type drop attribute then you need to some extra code as
$product->getData('brand')
only give brand option id not it label mean brand name example, Puma, addidas.Also, your module must have:
app/code/{Vendor}/{Modulename}/etc/module.xml
app/code/{Vendor}/{Modulename}/composer.json
app/code/{Vendor}/{Modulename}/registration.php
After adding the event you should flush the cache.