0

我想在卖家页面中显示树结构中的类别我是 Magento CE1.7 中的市场扩展我正在进入下拉列表但它看起来不太好。

有任何想法吗

<?php $_helper = Mage::helper('catalog/category') ?>
                <?php $_categories = $_helper->getStoreCategories() ?>
                <?php $currentCategory = Mage::registry('current_category') ?>
                <?php if (count($_categories) > 0): ?>
                    <select id="category" class="myinput-text required-entry widthinput" name="category">
                    <option value="">--Select Categories--</option>
                    <?php $_helper = Mage::helper('catalog/category') ?>
                    <?php $_categories = $_helper->getStoreCategories() ?>
                    <element onclick="<?php $currentCategory = Mage::registry('current_category') ?>">
                <?php if (count($_categories) > 0): ?>
                        <?php foreach($_categories as $_category): ?>
                            <option value="<?php echo $_category->getId() ?>">
                                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                                        <?php echo $_category->getName() ?></a>
                        </option>
                                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                                <?php $_subcategories = $_category->getChildrenCategories() ?>
                        <?php if (count($_subcategories) > 0): ?>
                                <?php foreach($_subcategories as $_subcategory): ?>
                                        <option value="<?php echo $_subcategory->getId() ?>">
                                        <?php echo '&nbsp;&nbsp;&nbsp;<img/>'; ?>
                                            <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                        <?php echo $_subcategory->getName() ?></a>
                            </option>
                                <?php $_subcategory = Mage::getModel('catalog/category/subcategory')->load($_subcategory->getId()) ?>
                                <?php $_subsubcategories = $_subcategory->getChildrenCategories() ?>
                        <?php if (count($_subsubcategories) > 0): ?>
                                <?php foreach($_subsubcategories as $_subsubcategory): ?>
                                        <option value="<?php echo $_subsubcategory->getId() ?>">
                                        <?php echo '&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;       '; ?>
                                        <a href="<?php echo $_helper->getCategoryUrl($_subsubcategory) ?>">
                        <?php echo $_subsubcategory->getName() ?></a>
                        </option>
                    <?php endforeach; ?>
                <?php endif; ?>
                            <?php endforeach; ?>
                        <?php endif; ?>
                        <?php endforeach; ?>
                <?php endif; ?></select>
                <?php endif; ?>

对不起每个人这不是重复的代码,在这个地方只有我需要改变,因为剩下的每件事都是完美的,它的 500 行代码

谢谢你

4

0 回答 0