Skip to main content
deleted 313 characters in body
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

Magento is managed it Category and product page breadcrumbs usingCategory and product page breadcrumbs using Mage_Catalog_Helper_Data class function getBreadcrumbPath function here magento

  check Category and product object is exits in current category depends on this magento create breadcrumbsCategory and product object is exits in current category depends on this magento create breadcrumbs.

You need to write this class

You need to write this class.

firstFirst depend on current category Pathcurrent category Path create an array which containing a hierarchical category tree ids hierarchical category tree ids then

 $pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
            $categories = $category->getParentCategories();

            // add category path breadcrumb
            foreach ($pathIds as $categoryId) {
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
            }

.

HOME->ALL CATEGORIES->TOPS->POLO-TOPSHOME->ALL CATEGORIES->TOPS->POLO-TOPS.

TOPS->POLO-TOPSTOPS->POLO-TOPS. that means you want only last category then

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    // put All Category id in loop to remove All category from crumns
           foreach ($pathIds as $categoryId) {
 
    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
 
            }
$breadcrumbsBlock->addCrumb('home', array(
                'label'=>Mage::helper('catalog')->__('Home'),
                'title'=>Mage::helper('catalog')->__('Go to Home Page'),
                'link'=>Mage::getBaseUrl()
            ));

Magento is managed it Category and product page breadcrumbs using Mage_Catalog_Helper_Data class function getBreadcrumbPath function here magento

  check Category and product object is exits in current category depends on this magento create breadcrumbs

You need to write this class

first depend on current category Path create an array which containing a hierarchical category tree ids then

 $pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
            $categories = $category->getParentCategories();

            // add category path breadcrumb
            foreach ($pathIds as $categoryId) {
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
            }

.

HOME->ALL CATEGORIES->TOPS->POLO-TOPS.

TOPS->POLO-TOPS. that means you want only last category then

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    // put All Category id in loop to remove All category from crumns
           foreach ($pathIds as $categoryId) {
 
    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
 
            }
$breadcrumbsBlock->addCrumb('home', array(
                'label'=>Mage::helper('catalog')->__('Home'),
                'title'=>Mage::helper('catalog')->__('Go to Home Page'),
                'link'=>Mage::getBaseUrl()
            ));

Magento is managed it Category and product page breadcrumbs using Mage_Catalog_Helper_Data class function getBreadcrumbPath function here magento check Category and product object is exits in current category depends on this magento create breadcrumbs.

You need to write this class.

First depend on current category Path create an array which containing a hierarchical category tree ids then

$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
$categories = $category->getParentCategories();

// add category path breadcrumb
foreach ($pathIds as $categoryId) {
    if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
        $path['category'.$categoryId] = array(
            'label' => $categories[$categoryId]->getName(),
            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
        );
    }
}

HOME->ALL CATEGORIES->TOPS->POLO-TOPS.

TOPS->POLO-TOPS. that means you want only last category then

$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));

$categories = $category->getParentCategories();

// add category path breadcrumb
// put All Category id in loop to remove All category from crumns
foreach ($pathIds as $categoryId) {
    $categoryId= end($pathIds);
    if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
        $path['category'.$categoryId] = array(
            'label' => $categories[$categoryId]->getName(),
            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
        );
    }
}
$breadcrumbsBlock->addCrumb('home', array(
    'label'=>Mage::helper('catalog')->__('Home'),
    'title'=>Mage::helper('catalog')->__('Go to Home Page'),
    'link'=>Mage::getBaseUrl()
));
added 46 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

HOMETOPS-> POLO>POLO-TOPS. that means you want only last category then

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    //remove put All Category id in loop
  to remove All category from crumns
        //   foreach ($pathIds as $categoryId) {

    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }

            //}

And for remove Home link from catalog page you need rewrite class

Mage_Catalog_Block_Breadcrumbs and and remove

$breadcrumbsBlock->addCrumb('home', array(
                'label'=>Mage::helper('catalog')->__('Home'),
                'title'=>Mage::helper('catalog')->__('Go to Home Page'),
                'link'=>Mage::getBaseUrl()
            ));

from rewrite code

HOME-> POLO-TOPS. that means you want only last category then

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    //remove loop
           //  foreach ($pathIds as $categoryId) {

    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }

            //}

TOPS->POLO-TOPS. that means you want only last category then

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    // put All Category id in loop to remove All category from crumns
           foreach ($pathIds as $categoryId) {

    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }

            }

And for remove Home link from catalog page you need rewrite class

Mage_Catalog_Block_Breadcrumbs and and remove

$breadcrumbsBlock->addCrumb('home', array(
                'label'=>Mage::helper('catalog')->__('Home'),
                'title'=>Mage::helper('catalog')->__('Go to Home Page'),
                'link'=>Mage::getBaseUrl()
            ));

from rewrite code

added 970 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

Note:

You need to write this class

first depend on current category Path create an array which containing a hierarchical category tree ids then

            $categories = $category->getParentCategories();

            // add category path breadcrumb
            foreach ($pathIds as $categoryId) {
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
            }

.

HOME->ALL CATEGORIES->TOPS->POLO-TOPS.

As you want to 

HOME-> POLO-TOPS. that means you want only last category then

you need modify code if it category page

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    //remove loop
          //  foreach ($pathIds as $categoryId) {

    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }

            //}

first depend on current category Path create an array which containing a hierarchical category tree ids then

            $categories = $category->getParentCategories();

            // add category path breadcrumb
            foreach ($pathIds as $categoryId) {
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
            }

.

Note:

You need to write this class

first depend on current category Path create an array which containing a hierarchical category tree ids then

            $categories = $category->getParentCategories();

            // add category path breadcrumb
            foreach ($pathIds as $categoryId) {
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }
            }

.

HOME->ALL CATEGORIES->TOPS->POLO-TOPS.

As you want to 

HOME-> POLO-TOPS. that means you want only last category then

you need modify code if it category page

            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));

            $categories = $category->getParentCategories();

            // add category path breadcrumb
    //remove loop
          //  foreach ($pathIds as $categoryId) {

    $categoryId= end($pathIds);
                if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                    $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
                    );
                }

            //}
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239
Loading