1

I need to display all my products like,

Sku    Name Price    Thumbnail      Add-to-cart(Button)

How can i get all above details on CMS Page?

Note : Add-To-Cart Error

2
  • You need to call phtml from cms page and then you can use the php functions or magento's functions to get image, sku, name, price etc on cms page. Commented Aug 7, 2018 at 8:26
  • May i know the complete path, i mean where i can place my phtml file {{block type="core/template" template="templateFolder/file_name.phtml"}},
    – zus
    Commented Aug 7, 2018 at 9:19

1 Answer 1

1

Please find the below the screen shot

enter image description here

In order to get the below product collection in cms page Please First create

Cms page under below at admin side.

Cms -> Pages -> Add New Page -> under content

Please find the below screen shots

enter image description here

enter image description here

And place the Product collection content under the template file in mentioned

file path: app/desgin/frontend/base/default/template/myphp/myphpcode.phtml

Place the below 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><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>
5
  • Everything okay, but addtocart not working.
    – zus
    Commented Aug 9, 2018 at 5:11
  • I will Check And Get back to you. Commented Aug 9, 2018 at 15:32
  • error is : ERR (3): Notice: Uninitialized string offset: 0 in C:\wamp\www\magento\app\code\local\Cmsmart\AjaxCart\controllers\IndexController.php on line 209
    – zus
    Commented Aug 11, 2018 at 4:51
  • All are working, except Add-To-Cart.
    – zus
    Commented Aug 14, 2018 at 11:39
  • <?php echo $this->__('Add to Cart'] ?> this one fatal error, can i get any help?
    – zus
    Commented Aug 17, 2018 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.