cancel
Showing results for 
Search instead for 
Did you mean: 

Add-To-Cart Buttom Error In CMS Page

Add-To-Cart Buttom Error In CMS Page

Code : 

<?php
$_productCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*');
?>
<table>
<tr>
<th class="prosku">Sku</th>
<th class="proname">Name</th>
<th class="proprice">Price</th>
<th class="proimg">Thumbnail</th>
<th class="pro-button">Add to Cart Button</th>
</tr>
<?php
if(count($_productCollection))
{
foreach($_productCollection as $product)
{
?>
<tr>
<td class="prodsku"><?php echo $product->getSku(); ?></td>
<td class="prodname"><?php echo $product->getName();?></td>
<td class="prodprice"><?php echo $product->getPrice();?></td>
<td class="prodimg"><img src="<?php echo $product->getImageUrl();?>" width="100px" height="100px"/></td>

<td class="prod-add_to_Cart-button">

<?php if($product->isSaleable()): ?>

<p>

<!-- add to cart button -->

<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($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>

</p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?></td>
</tr>
<?php
}
}
?>
</table>
<style type="text/css">
.prodsku, .prodname, .prodprice, .prodimg, .prod-add_to_Cart-button{
padding:10px;
}
.prosku, .proname, .proprice, .proimg, .pro-button{
padding:10px;
}
</style>