我制作了一个小型 magento (1.7) 模板文件,显示一个类别中的所有产品。但是,它们仅显示在单个列中。我想在 2 列中显示。
这从首页执行块:
{{block type="catalog/product" name="msc.specials" template="mylib/featuredlist.phtml"}}
这是 featureslist.phtml -
<?php
//$_categoryId = $this->getCategoryId();
$productCollection = Mage::getModel('catalog/category')->load(4)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->setOrder('price', 'ASC');
$cartHelper = Mage::helper('checkout/cart');
?>
<div class='block block-list'>
<div class='block-title'><strong><span><?php echo $this->__('SPECIALS') ?></span></strong></div>
<div class='block-content'>
<ul>
<h2><?php echo $this->__( $this->getLabel() ); ?></h2>
<?php foreach ($productCollection as $product): ?>
<div class="item">
<a class="product-image" href="<?php echo $product->getProductUrl() ?>">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(100); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($product, 'small_image')) ?>" />
</a>
<a class="product-name" href="<?php echo $product->getProductUrl() ?>"><?php echo $this->htmlEscape($product->getName()) ?></a>
<?php echo $this->getPriceHtml($product, true) ?>
</div>
<div class="cms-price-box" style=" text-align:center;"></div>
<div class="button-row" style="text-align:center;">
<button class="button btn-cart" type="button" onclick="setLocation('<?php echo $this->getUrl('')."checkout/cart/add?product=".$product->getId()."&qty=1" ?>')" class="button"><span><?php echo $this->__('Add to Cart') ?></span></button>
</div>
<br/><br/>
<?php endforeach ?>
</ul>
</div>
</div>