public function getMetaFromElement($element)
{
/* -- See if there is an 'entry' automagically put into this template, and if it contains an Seomatic_Meta */
$entryMeta = null;
if (isset($element) && $element) {
$elemType = $element->getElementType();
if ($elemType == ElementType::Entry || $elemType == "Commerce_Product" || $elemType == ElementType::Category) {
$attributes = $element->content->attributes;
foreach ($attributes as $key => $value) {
if (is_object($value) && property_exists($value, "elementType")) {
if ($value->elementType == "Seomatic_FieldMeta") {
if ($this->isFieldHandleInEntry($element, $key)) {
$entryMeta = $value;
$this->lastElement = $element;
/* -- If this is a Commerce Product, fill in some additional info */
if ($elemType == "Commerce_Product" && craft()->config->get("renderCommerceProductJSONLD", "seomatic")) {
$commerceSettings = craft()->commerce_settings->getSettings();
$variants = $element->getVariants();
$commerceVariants = array();
foreach ($variants as $variant) {
$commerceVariant = array('seoProductDescription' => $variant->getDescription(), 'seoProductPrice' => number_format($variant->getPrice(), 2, '.', ''), 'seoProductCurrency' => $commerceSettings['defaultCurrency'], 'seoProductSku' => $variant->getSku());
$commerceVariants[] = $commerceVariant;
}
if (!empty($commerceVariants)) {
$entryMeta['seoCommerceVariants'] = $commerceVariants;
}
}
}
/* -- Swap in any SEOmatic fields that are pulling from other entry fields */
}
}
}
}
}
return $entryMeta;
}