1

我没有从儿童类别中获得所有图像,请帮助我。

潘卡伊

<table id="t2">
    <tr>
    <?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
    <td>
        <div class="product_2">
            <?php if($_imgUrl): ?>
            <div class="product_img2"><a href="<?php echo $_subcat->getUrl() ?>"><img src="<?php echo $_category->getImageUrl() ?>"  alt="<?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?>" /></a></div><p class="text-1"><a href="<?php echo $_subcat->getUrl() ?>"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?></a></p>
                </div>
    </td>
        <?php endif; ?>
    <?php endforeach ?>
    </tr>
</table>
4

3 回答 3

1

你也可以试试这个。

$_subcat->getThumbnailImageUrl()
于 2013-10-23T06:25:50.357 回答
1

你可以如下

<?php
    //gets all sub categories of parent category
    $cats = Mage::getModel('catalog/category')->load(your category id)->getChildren();
    $catIds = explode(',',$cats);
$categories = array();
foreach($catIds as $catId) {
    $category = Mage::getModel('catalog/category')->load($catId); 
    $categories[$category->getName()] = array(
        'url' => $category->getUrl(),
        'img' => $category->getImageUrl()
    );
}

ksort($categories, SORT_STRING); // for sorting purpose 

?>

<ul>
    <?php foreach($categories as $name => $data): ?>
        <li>
            <a href="<?php echo $data['url']; ?>" title="<?php echo $name; ?>">
                <img class="cat-image" src="<?php echo $data['img']; ?>" />
            </a>
        </li>   
    <?php endforeach; ?>
</ul>

希望这对你有用,

于 2013-10-23T06:50:16.387 回答
0

更新代码:

<table id="t2">
<tr>
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<td>
    <div class="product_2">
        <?php // if($_imgUrl):  remove condition?>
        <div class="product_img2">
            <a href="<?php echo $_subcat->getUrl() ?>">
                <!-- Updated below line code, use $_subcat in stead of $_category -->
                <img src="<?php echo $_subcat->getImageUrl(); ?>"  alt="<?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?>" /></a>
        </div>
        <p class="text-1">
            <a href="<?php echo $_subcat->getUrl() ?>"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?></a>
        </p>
    </div>
</td>
<?php // endif; remove condition?>  
<?php endforeach ?>
</tr>

希望会奏效!

于 2013-10-23T13:41:06.813 回答