my product details page has url structure like
url > cat > sub cat > product name
but in breadcrumb i see only home > product name i want to show category and sub category also
breadcrum.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var \Magento\Theme\Block\Html\Breadcrumbs $block */
/** @var \Magento\Catalog\ViewModel\Product\Breadcrumbs $viewModel */
$viewModel = $block->getData('viewModel');
?>
<div class="ui breadcrumb" data-mage-init='{
"breadcrumbs": {
"categoryUrlSuffix": "<?= $block->escapeHtml($viewModel->getCategoryUrlSuffix()); ?>",
"useCategoryPathInUrl": <?= (int)$viewModel->isCategoryUsedInProductUrl(); ?>,
"product": "<?= $block->escapeHtml($block->escapeJsQuote($viewModel->getProductName(), '"')); ?>"
}
}'>
</div>
layout.xml file
<referenceBlock name="breadcrumbs" template="Magento_Catalog::product/breadcrumbs2.phtml">
<arguments>
<argument name="viewModel" xsi:type="object">Magento\Catalog\ViewModel\Product\Breadcrumbs</argument>
</arguments>
</referenceBlock>