web hosting
build a website

Display catalog products into Magento static pages

Apr 5, 2013   //   by Anthony Devine   //   Website Development tips  //  Comments Off on Display catalog products into Magento static pages

There maybe a time when you may want to create a page on your Magento site which pulls in products from multiple categories you have setup. I have recently setup a page where I needed to display a heading saying Summer clothing and then text underneath it and then under that a few example of Summer clothing and then under that the same again for Spring and Winter all on the same page.

The way I got round this was to create 3 new categories; Summer, Spring and Winter and then in each of those categories add in 4 products. Once these categories were setup and an index was run on the Website I then created a static page with all of the relevant text and heading that I wanted on the page and where I wanted the products to appear I used the following code:

{{block type="catalog/product_list" category_id="281" template="catalog/product/list.phtml"}}
The code basically pulls in all products from the category with the ID 281. The Category ID is found when you click on your category it will show the ID at the top next to the name. The link to the block type and the template in the above code may differ for each installation of Magento as the file structure maybe different but this can easily be located using FTP. The above code is used 3 times on the page for the Summer products, Spring products and Winter products each with their own ID numbers.

Once the products have been pulled in you can then style the CSS to make them look as you wish.

Using this method helped me out enormously as it is dynamic and the prices and links will always be correct even when they are altered. Previously I was adding in the images, prices and links manually and finding it to take a long time to do and also hard to make sure it is all up-to-date.

If you find that this does not work for you then first make sure that you categories are enabled and your products that are in your categories are live and are in stock. Then run an index and clear your cache, then check that your IDs are correct and also check to make sure that the links to the product_list and list.phtml are correct.

You can also create your own phtml file and link to that. So if you want extra features added to your products such as a Javascript gallery effect to them, then you can duplicate the list.phtml file and name it something different and in that file add in the relevant javascript code and then upload this file and change the links to the file in your static page.