如何在Magento的CMS页面中按类别显示产品?(How do display products by category in CMS page in Magento?)

我有一个名为“产品”的页面。 在这个页面中,我需要显示所有与它对应的类别名称分离的项目。 结构如下所示

category 1 item1 item2 category 2 item1 item2

我怎样才能做到这一点?

i have one page with the name "products". in this page i need to display all the items seperated by it's corresponding category name. the structure looks like below

category 1 item1 item2 category 2 item1 item2

how can i do this?

最满意答案

{{block type="catalog/product_list" category_id="8" template="catalog/product/featured.phtml"}}

在cms页面中添加上面的代码并在catalog / product中添加featured.phtml文件并放入此代码

<?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?> <div class="note-msg"> <?php echo $this->__('There are no products matching the selection. Please provide a category ID.') ?> </div> <?php else: ?> <?php // Grid Mode ?> <ul id="featured" class="jcarousel-skin-tango"> <?php $_collectionSize = $_productCollection->count() ?> <?php $i=0; foreach ($_productCollection as $_product): ?> <?php if($i++%4==0): ?> <?php endif ?> <li><a class="preview" rel="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 300); ?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(105, 105); ?>" width="105" height="105" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> </a> </li> <?php if ($i%4==0 && $i!=$_collectionSize): ?> <?php endif ?> <?php endforeach ?> </ul> <?php endif; ?> {{block type="catalog/product_list" category_id="8" template="catalog/product/featured.phtml"}}

add above code in cms page and add featured.phtml file in catalog/product and put this code

<?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?> <div class="note-msg"> <?php echo $this->__('There are no products matching the selection. Please provide a category ID.') ?> </div> <?php else: ?> <?php // Grid Mode ?> <ul id="featured" class="jcarousel-skin-tango"> <?php $_collectionSize = $_productCollection->count() ?> <?php $i=0; foreach ($_productCollection as $_product): ?> <?php if($i++%4==0): ?> <?php endif ?> <li><a class="preview" rel="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 300); ?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(105, 105); ?>" width="105" height="105" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> </a> </li> <?php if ($i%4==0 && $i!=$_collectionSize): ?> <?php endif ?> <?php endforeach ?> </ul> <?php endif; ?>如何在Magento的CMS页面中按类别显示产品?(How do display products by category in CMS page in Magento?)

我有一个名为“产品”的页面。 在这个页面中,我需要显示所有与它对应的类别名称分离的项目。 结构如下所示

category 1 item1 item2 category 2 item1 item2

我怎样才能做到这一点?

i have one page with the name "products". in this page i need to display all the items seperated by it's corresponding category name. the structure looks like below

category 1 item1 item2 category 2 item1 item2

how can i do this?

最满意答案

{{block type="catalog/product_list" category_id="8" template="catalog/product/featured.phtml"}}

在cms页面中添加上面的代码并在catalog / product中添加featured.phtml文件并放入此代码

<?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?> <div class="note-msg"> <?php echo $this->__('There are no products matching the selection. Please provide a category ID.') ?> </div> <?php else: ?> <?php // Grid Mode ?> <ul id="featured" class="jcarousel-skin-tango"> <?php $_collectionSize = $_productCollection->count() ?> <?php $i=0; foreach ($_productCollection as $_product): ?> <?php if($i++%4==0): ?> <?php endif ?> <li><a class="preview" rel="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 300); ?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(105, 105); ?>" width="105" height="105" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> </a> </li> <?php if ($i%4==0 && $i!=$_collectionSize): ?> <?php endif ?> <?php endforeach ?> </ul> <?php endif; ?> {{block type="catalog/product_list" category_id="8" template="catalog/product/featured.phtml"}}

add above code in cms page and add featured.phtml file in catalog/product and put this code

<?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?> <div class="note-msg"> <?php echo $this->__('There are no products matching the selection. Please provide a category ID.') ?> </div> <?php else: ?> <?php // Grid Mode ?> <ul id="featured" class="jcarousel-skin-tango"> <?php $_collectionSize = $_productCollection->count() ?> <?php $i=0; foreach ($_productCollection as $_product): ?> <?php if($i++%4==0): ?> <?php endif ?> <li><a class="preview" rel="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 300); ?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(105, 105); ?>" width="105" height="105" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> </a> </li> <?php if ($i%4==0 && $i!=$_collectionSize): ?> <?php endif ?> <?php endforeach ?> </ul> <?php endif; ?>