(Magento)显示产品列表

时间:2014-08-05 11:07:33

标签: css

如何在列表中显示产品?

1 个答案:

答案 0 :(得分:0)

将list.phtml的整个代码替换为此...

<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<table id="itemtable" style="width:100%;">
<thead><tr><th>Name</th><th>Short description</th><th>Brand</th><th>Price With Tax</th><th>Price Without Tax</th><th>Add To Cart</th></tr></thead>
<tbody>
<?php foreach ($_productCollection as $_product): ?>
    <tr class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
        <td><?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></td>
        <td><?php echo $_product->getShortDescription(); ?></td>
        <td>brand</td>
        <td><?php 
        $_priceIncludingTax = Mage::helper('tax')->getPrice($_product, $_product->getPrice(), true, null, null, null, null, false);
        echo $_priceIncludingTaxWithCurrency = Mage::helper('core')->currency($_priceIncludingTax); ?></td>
        <td><?php 
        $_priceExcludingTax = Mage::helper('tax')->getPrice($_product, $_product->getPrice(), false, null, null, null, null, false);
        echo $_priceExcludingTaxWithCurrency = Mage::helper('core')->currency($_priceExcludingTax); ?></td>
        <td>
        <?php if($_product->isSaleable() && !$_product->canConfigure()): ?>
       <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId(); ?>"><input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" /><button class="form-button" onclick="productAddToCartForm_<?php echo $_product->getId(); ?>.submit()"><span><?php echo $this->__('Add to Cart'); ?></span></button></form>
       <script type="text/javascript"> var productAddToCartForm_<?php echo $_product->getId(); ?> = new VarienForm('product_addtocart_form_<?php echo $_product->getId(); ?>');    productAddToCartForm_<?php echo $_product->getId(); ?>.submit = function(){ if (this.validator.validate()) {    this.form.submit(); }   }.bind(productAddToCartForm_<?php echo $_product->getId(); ?>);</script>
        <?php endif;?>
        </td>
    </tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php endif; ?>

<div class="toolbar-bottom">
    <?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>

<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach($_afterChildren as $_afterChildName):
    $_afterChild = $this->getChild('after')->getChild($_afterChildName);
    $_afterChild->setProductCollection($_productCollection);
?>
<?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
<style>
#itemtable th{ font-weight:bold!important;text-align:center!important;}
#itemtable tr{ height:50px!important;}
#itemtable tr td{ text-align:center!important;}
</style>

如果您有任何疑问,请告诉我......