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?