Skip to content

Commit

Permalink
Fix product breadcrumbs generation for luma
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Aug 28, 2024
1 parent 43d5e1c commit 7d5cf6f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion view/frontend/templates/product/breadcrumbs.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
declare(strict_types=1);

use Magento\Catalog\Helper\Data as CatalogHelper;
use Magento\Catalog\ViewModel\Product\Breadcrumbs;
use Magento\Framework\Json\Helper\Data;
use Magento\Theme\Block\Html\Breadcrumbs as BreadcrumbsBlock;
Expand All @@ -18,7 +19,16 @@ $viewModel = $block->getData('viewModel');
$config = $block->getData('breadcrumbsConfig');
?>
<?php if ($config->isServerSideRendered()): ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Theme::html/breadcrumbs.phtml')) ?>
<?php
/** @var CatalogHelper $catalogHelper */
$catalogHelper = $this->helper(CatalogHelper::class);
/** @var BreadcrumbsBlock $breadcrumbs */
$breadcrumbs = $block->getLayout()->createBlock(BreadcrumbsBlock::class);
foreach ($catalogHelper->getBreadcrumbPath() as $name => $crumb) {
$breadcrumbs->addCrumb($name, $crumb);
}
?>
<?= $breadcrumbs->toHtml() ?>
<?php else: ?>
<div class="breadcrumbs"></div>
<?php endif; ?>
Expand Down

0 comments on commit 7d5cf6f

Please sign in to comment.