How can magento display products on the homepage?

Source: Internet
Author: User

1. Create a new category in the magento background and write down the ID number of the category. Use the new category to manage your homepage products. This category is invisible to the foreground. This will not be displayed in your category menu, but will be displayed when you call the code.

2. Add the following code (for example, the final part of the Code) to the appropriate location of CMS-> Manage page-> Home)
{Block type = "CATALOG/product_list" category_id = "3" template = "CATALOG/product/list. phtml "}}

(Note the encoding. You may not be able to copy and paste it directly. If the English punctuation marks are not available, switch to the English input method and manually click it. Close your WYSIWYG editor and paste the code in "content" in the example)

If XML is used for display, add the following XML code in "design", for example:

<Reference name = "content">
<Block type = "catalog/product_list" name = "featured" template = "catalog/product/list. phtml">
<Action method = "setcategoryid"> <category_id> [Category ID here] </category_id> </Action>
</Block>
</Reference>

The code is explained as follows:

Create a category in the magento background. Products added to this category are displayed on the homepage. After Magneto successfully adds a category, an ID is assigned to the category. The value "3" for the red part "category_id" is both the category ID. "List. phtml" is a template Style File for this product list.

The template in XML refers to the template path, including the ID number of your category deleted from the brackets. If you want to display the product on the homepage, add the XML section to the layout update of the CMS homepage page in the background. For example

 

Reprinted Please note: Hi cool, you are cool! » How does magento display products on the home page?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.