$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
$current_cat = $category->getId(); // current category id
$parent_cat = $category->getParentCategory()->getId(); // parent category id
foreach ($category->getParentCategories() as $parent) {
$catids[] = $parent->getId(); // show all parent cat ids and self id in an array
}
if($catids[0]==parent_cat_id){
echo "show parent cat custom code";
}
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
$current_cat = $category->getId(); // current category id
$parent_cat = $category->getParentCategory()->getId(); // parent category id
foreach ($category->getParentCategories() as $parent) {
$catids[] = $parent->getId(); // show all parent cat ids and self id in an array
}
if($catids[0]==parent_cat_id){
echo "show parent cat custom code";
}
No comments:
Post a Comment