0
存在类别时获得空白页
我目前在sidebar.phtml代码Magento的2:检查是否在侧边栏
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
if($category->getId()==503){
echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('automation_tissue_processors')->toHtml();
}
?>
当我在面包屑与种类的页面上,它工作正常
Home > Instruments > automation-tissue-processors-embedders.html
问题是当面包屑中没有分类我得到一个空白页
Home > automation-tissue-processors-embedders.html
这种情况发生在我点击产品来自搜索结果
有什么办法解决这个问题?