Amit's answer is correct. However, Google limits the description to 255 characters. That is why I have limited the characters of the description to 255. I have also removed any new lines and html tags, if used in the description.
if ($product instanceof \Magento\Catalog\Model\Product) {
$newMetaDescription = $product->getData('brand').' '. $product->getData('name') .'-'. __('buy online today');
$shortMetaDescription = str_replace(array("\n", "\r"),' ',strip_tags(substr($newMetaDescription, 0, 255)));
$product->setMetaDescription($shortMetaDescription);
I have also added the 'brand' attribute to the Meta Title and put the title in the Meta Keywords. Then put a comma after each word in the keywords. So if the new title is "New black tshirt Nike", the Meta Keywords, would be "new, black, tshirt, nike". Here is the code:
$pageMainTitle = $product->getData('name');
$newMetaTitle = $pageMainTitle .$product->getData('brand');
$product->setMetaTitle($newMetaTitle);
$newKeywords = str_replace(' ',", ",$newMetaTitle);
$product->setMetaKeyword($newKeywords);