我想在System.xml中将我的模块的管理员侧的所有产品类别显示为多选。
$_category = Mage::getModel('catalog/category')->load();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
foreach($collection as $cat){
if($_category->getIsActive()){
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$helper->getCategoryUrl($cat);
echo $cat->getName();
}
}
但是它不会显示我想要的东西,我只想要产品类别......可以对它有所了解...... Thanx。
答案 0 :(得分:2)
要在系统配置中显示类别选择,我已经通过扩展Mage模型类和方法找到了解决方案。
Mage_Adminhtml_Model_System_Config_Source_Category
并删除该行。
->addPathFilter('^1/[0-9]+$')
现在它在系统配置中显示多选项。您可以从列表中选择多个类别..
答案 1 :(得分:2)
我正在研究Magento 1.7,但我没有看到包含的行 - > addPathFilter( '^ 1 / [0-9] + $')
但是,删除以下行对我有用。 - > addRootLevelFilter()
答案 2 :(得分:1)
?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo "<b>".$_category->getName(). $_category->getId()."</b>" ?>
</a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo "--".$_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>