1

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>
1

2 Answers 2

1

You can use this module for display category and subcategory in breadcrum on prodcut detail page

https://github.com/EaDesgin/magento2-full-path-category-product-breadcrumb

0

You can use below reference URL for display category and subcategory in breadcrumbs on the product detail page:

Magento 2.3. - Show fullpath in breadcrumb on product detail page

OR

As Sanket posted you can use below module:

https://github.com/EaDesgin/magento2-full-path-category-product-breadcrumb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.