Magento首页设置显示指定目录的产品

先查看Magento这种设置指定目录产品到首页
的方法的效果图:

Magento首页显示指定目录产品的效果图

1.在Page的home里添加:{{block type="catalog/product_list" category_id="28" products_count="9" template="catalog/product/home.phtml"}}

注:category_id是指定的目录ID,products_count是要显示的产品数。

2.home.phtml的内容为

<?php
    $_products=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
?>
<?php if(!$_products->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<h2 class="subtitle"><?php echo $this->__('BMD Exclusives') ?></h2>
<?php $_columnCount =3;$limit=isset($this->products_count)?(int)$this->products_count:6; ?>
    <?php $i=0;foreach ($_products as $_product): ?>
    <?php if ($limit<=$i){ break;} ?>
        <?php if ($i++%$_columnCount==0): ?>
        <ul class="products-grid">
        <?php endif ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
                <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php echo $this->getPriceHtml($_product, true, '-new') ?>
                <div class="actions">
                    <?php if($_product->isSaleable()): ?>
                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                    <ul class="add-to-links">
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                        <?php endif; ?>
                        <?php if ($_compareUrl = $this->getAddToCompareUrl($_product)): ?>
                            <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </li>
        <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
        </ul>
        <?php endif ?>
    <?php endforeach; ?>
<?php endif; ?>

跟以前Magento首页显示什么什么的一样。。代码备份文

本文永久地址:https://sjolzy.cn/Magento-Home-Set-display-products-specified-directory.html

--EOF--

随机文章

已有 8 条评论

  1. jacobjacob

    你好,别人做100你做2 50,哈哈

  2. 这些都是高科技产品啊

  3. Lol,test for ajax,not ad.

    1. 你也用emlog

  4. 这次的改版很漂亮。希望越办越好。
    有空去我博客看看。给点建议http://www.uggyes.com
    谢谢!

    1. 嘿嘿, 你这个站真不错!

添加新评论