2013-01-15 79 views
0

在我的Magento主页上,我尝试列出来自某个类别的子类别以及来自其中的自定义类别属性的某些值。该列表正在工作,但我无法从自定义类别属性中获取值。从类别页面以外的自定义类别属性中获取值

输出为空白。我做错了什么?相关的属性是category_subtitle和category_slidertext。

<?php 
    $_helper = Mage::helper('catalog/category'); 
    $productsChildren = Mage::getModel('catalog/category')->getCategories(3); 
    foreach ($productsChildren as $productCat) { 
?> 
<li> 
    <div class="content-wrapper"> 
     <div class="content"> 
      <h2><?php $_category_subtitle = $productCat->getData('category_subtitle'); if($_category_subtitle): ?><span><?php echo $_category_subtitle; ?></span><?php endif; ?></h2> 
      <?php $_category_slidertext = $productCat->getData('category_slidertext'); if($_category_slidertext): ?><h3><?php echo $_category_slidertext; ?></h3><?php endif; ?> 
      <a href="<?php echo $_helper->getCategoryUrl($productCat) ?>"><?php echo $this->__('View our products') ?> &gt;</a> 
     </div> 
    </div> 
</li> 
<?php } ?> 

回答

0

尝试:

$productsChildren = Mage::getModel('catalog/category')->getCategories(3,0,false,true,false); 
$productsChildren->addAttributeToSelect('category_subtitle') 
        ->addAttributeToSelect('category_slidertext'); 

如果$productsChildren是集合类的一个实例,将工作。

相关问题