本文整理汇总了PHP中Magento\Catalog\Helper\Data::getBreadcrumbPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getBreadcrumbPath方法的具体用法?PHP Data::getBreadcrumbPath怎么用?PHP Data::getBreadcrumbPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Helper\Data
的用法示例。
在下文中一共展示了Data::getBreadcrumbPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareLayout
/**
* Preparing layout
*
* @return \Magento\Catalog\Block\Breadcrumbs
*/
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl()]);
$title = [];
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title[] = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return parent::_prepareLayout();
}
示例2: testGetBreadcrumbPath
/**
* @magentoDataFixture Magento/Catalog/_files/categories.php
*/
public function testGetBreadcrumbPath()
{
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Category');
$category->load(5);
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get('Magento\\Framework\\Registry')->register('current_category', $category);
try {
$path = $this->helper->getBreadcrumbPath();
$this->assertInternalType('array', $path);
$this->assertEquals(['category3', 'category4', 'category5'], array_keys($path));
$this->assertArrayHasKey('label', $path['category3']);
$this->assertArrayHasKey('link', $path['category3']);
$objectManager->get('Magento\\Framework\\Registry')->unregister('current_category');
} catch (\Exception $e) {
$objectManager->get('Magento\\Framework\\Registry')->unregister('current_category');
throw $e;
}
}