我有这个显示悬停效果的代码并显示子菜单,但它们不会按照管理员中的显示进行排序。我尝试使用getChildrenCategories()但是这不会返回数据。请帮忙。
<?php
$_helper = Mage::helper('catalog/category');
$_currentCat = Mage::registry('current_category');
$_categories = $_helper->getStoreCategories();
if(!Mage::registry('current_product')) {
if ( count( $_categories ) > 0 ) {
?>
<nav class="site_nav sub" id="shop_sub_nav">
<ul>
<?php foreach ( $_categories as $_category ): ?>
<li class="menu-item-has-children <?= ( $active === 'shop' ) ? 'current-menu-item' : ''; ?>">
<a href="<?php echo $_helper->getCategoryUrl( $_category ) ?>">
<?php echo $_category->getName() ?>
</a>
<ul class="cat_hover_nav sub-menu" style="width: 190px;">
<?php
$loadCategory = Mage::getModel( 'catalog/category' )->load( $_category->getId() );
$subCategories = explode( ',', $loadCategory->getChildren() );
?>
<?php
if ( count( $subCategories ) > 0 ) {
echo '<ul>';
foreach ( $subCategories as $subCategoryId ) {
$cat = Mage::getModel( 'catalog/category' )->load( $subCategoryId );
echo '<li class="' . ( ( $this->isCategoryActive( $cat ) ) ? 'current-menu-item' : '' ) . '"><a href="' . $cat->getURL() . '">' . $cat->getName() . '</a></li>';
}
echo '</ul>';
}
?>
</ul>
</li>
<?php endforeach; ?>
</ul>
</nav>
<?php
}
}