) - same value
// already used for the Brand node's own name, reused here for CollectionPage.name too,
// genuinely different from the
tag text.
$pageTitle = $splashPage->getName();
$pageDescription = $headBlock ? trim($headBlock->getDescription()) : '';
$breadcrumbItems = array(
array('@type' => 'ListItem', 'position' => 1, 'name' => Mage::helper('catalog')->__('Home'), 'item' => $baseUrl),
);
if ($splashGroup) {
$breadcrumbItems[] = array('@type' => 'ListItem', 'position' => 2, 'name' => $splashGroup->getName(), 'item' => $splashGroup->getUrl());
}
$breadcrumbItems[] = array('@type' => 'ListItem', 'position' => count($breadcrumbItems) + 1, 'name' => $splashPage->getName());
$brand = array(
'@type' => 'Brand',
'@id' => $pageUrl . '#brand',
'name' => $splashPage->getName(),
'url' => $pageUrl,
);
if ($splashPage->getThumbnail()) {
$brand['logo'] = $splashPage->getThumbnail();
}
// Same {{widget type="stenik_sitewidget/widget_category"...}} raw-content-parsing approach as
// the Земеделие/Строителство hub categories (catalog/category/new-machines-schema.phtml) -
// these tiles link to internal category pages, not to products, so no "multiple Product
// entities" risk either way; flat name/url matches that established pattern exactly.
$listItems = array();
if ($splashPage->getDisplayMode() == Mage_Catalog_Model_Category::DM_PAGE && $splashPage->getCmsBlock()) {
$cmsBlock = Mage::getModel('cms/block')->setStoreId($store->getId())->load($splashPage->getCmsBlock());
$content = $cmsBlock->getContent();
if (preg_match_all('/{{widget\s+type="stenik_sitewidget\/widget_category"([^}]*)}}/i', $content, $widgetMatches)) {
$position = 0;
foreach ($widgetMatches[1] as $widgetParams) {
if (!preg_match('/\btitle="([^"]*)"/', $widgetParams, $titleMatch)) {
continue;
}
if (!preg_match('/\burl="([^"]*)"/', $widgetParams, $urlMatch)) {
continue;
}
$tileUrl = trim($urlMatch[1]);
if ($tileUrl && strpos($tileUrl, 'http') !== 0) {
$tileUrl = $baseUrl . ltrim($tileUrl, '/');
}
$position++;
$listItems[] = array(
'@type' => 'ListItem',
'position' => $position,
'name' => trim($titleMatch[1]),
'url' => $tileUrl,
);
}
}
}
$collectionPageNode = array(
'@type' => 'CollectionPage',
'@id' => $pageUrl . '#webpage',
'url' => $pageUrl,
'name' => $pageTitle,
'inLanguage' => str_replace('_', '-', Mage::app()->getStore()->getConfig('general/locale/code')),
'isPartOf' => array('@id' => $baseUrl . '#website'),
'about' => array('@id' => $pageUrl . '#brand'),
'breadcrumb' => array('@id' => $pageUrl . '#breadcrumb'),
);
if ($pageDescription) {
$collectionPageNode['description'] = $pageDescription;
}
if ($listItems) {
$collectionPageNode['mainEntity'] = array('@id' => $pageUrl . '#itemlist');
}
$graph = array(
array(
'@type' => 'BreadcrumbList',
'@id' => $pageUrl . '#breadcrumb',
'itemListElement' => $breadcrumbItems,
),
$collectionPageNode,
$brand,
);
if ($listItems) {
$graph[] = array(
'@type' => 'ItemList',
'@id' => $pageUrl . '#itemlist',
'numberOfItems' => count($listItems),
'itemListElement' => $listItems,
);
}
$graph[] = array(
'@type' => 'Organization',
'@id' => $baseUrl . '#organization',
'name' => 'Titan Machinery Bulgaria',
'url' => $baseUrl,
'logo' => array('@id' => $baseUrl . '#logo'),
);
$graph[] = array(
'@type' => 'WebSite',
'@id' => $baseUrl . '#website',
'url' => $baseUrl,
'name' => 'Titan Machinery Bulgaria',
);
$schema = array(
'@context' => 'https://schema.org',
'@graph' => $graph,
);
?>