最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

magento 通过目录ID输出指定分类

Magento 资料整理 ajiang-tuzi 4590浏览

//phtml 文件

<h1>custom category</h1>
<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
 
<?php $_iterator = 0; ?>
 
<?php foreach ($_productCollection as $_product): ?>
 
<?php //image ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(150); ?>" width="150″ height="150″ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<?php // title description ?>
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<p>title:</p>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>
<p>price:</p>
<?php echo $this->getPriceHtml($_product, true) ?>
 
<?php endforeach; ?>
<?php endif; ?>

//引用

<reference name="content">
    <block type="catalog/product_list" name="custom.category" template="custom/custom_category.phtml">
        <action method="setCategoryId"><category_id>3</category_id></action>
    </block>
</reference>

{{block type="catalog/product_list" category_id="28" products_count="9" template="custom/custom_category.phtml"}}

//看不太懂的请移步到这篇文章
Magento首页自定义调用目录

转载请注明:(●--●) Hello.My Weicot » magento 通过目录ID输出指定分类

蜀ICP备15020253号-1