public function getProductJSONLD($meta, $identity, $locale)
{
/* -- Cache it in our class; no need to fetch it more than once */
if (isset($this->cachedProductJSONLD[$locale])) {
return $this->cachedProductJSONLD[$locale];
}
$productsArrayJSONLD = array();
foreach ($this->entrySeoCommerceVariants as $variant) {
$productJSONLD = array();
/* -- Product JSON-LD */
$productJSONLD['type'] = "Product";
$productJSONLD['name'] = $variant['seoProductDescription'];
$productJSONLD['description'] = $meta['seoDescription'];
$productJSONLD['image'] = $meta['seoImage'];
$productJSONLD['logo'] = $meta['seoImage'];
$productJSONLD['url'] = $meta['canonicalUrl'];
$productJSONLD['mainEntityOfPage'] = $meta['canonicalUrl'];
$productJSONLD['sku'] = $variant['seoProductSku'];
$offer = array("type" => "Offer", "url" => $meta['canonicalUrl'], "price" => $variant['seoProductPrice'], "priceCurrency" => $variant['seoProductCurrency'], "offeredBy" => $identity, "seller" => $identity);
$offer = array_filter($offer);
$productJSONLD['offers'] = $offer;
$productsArrayJSONLD[] = array_filter($productJSONLD);
}
$this->cachedProductJSONLD[$locale] = $productsArrayJSONLD;
return $productsArrayJSONLD;
}