Show CATEGORY and its products on the Magento1.9 homepage

I want to show a category with its products on the main page. Magento has a built-in option for showing new products on the home page, and I have no idea how to display different categories on the main page. For example, I created a category, and I want to show the products of this category on the home page, as shown below:

Featured Products

Product1 Product2 Product3

I tried under the code (from previous posts)

{{block type="catalog/product_new" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}} 

But it gives me an error below

 Fatal error: Call to a member function getSortedChildren() on a non-object in C:\wamp\www\magento1901\app\design\frontend\rwd\default\template\catalog\product\list.phtml on line 134 

Obviously, the code mentioned above refers to previous versions or Magento. However, version 1.9.0.1 gives an error.

Please indicate how to show categories on the home page. Thanks

+1
source share
2 answers

for the new product list in magento 1.9 use this

  {{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}} 

enter image description here or categorical list

The new RWD design has two child blocks for the product list. more details

 <block type="core/text_list" name="product_list.name.after" as="name.after" /> <block type="core/text_list" name="product_list.after" as="after" /> 

You can first call your block on the CMS main page, as shown below:

 {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}} 

Now in your /product/list.phtml directory find line number 74: and 133

find this code

 <?php $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); foreach($_nameAfterChildren as $_nameAfterChildName): $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); $_nameAfterChild->setProduct($_product); ?> <?php echo $_nameAfterChild->toHtml(); ?> <?php endforeach; ?> 

replace

 <?php if($this->getChild('name.after')): $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); foreach($_nameAfterChildren as $_nameAfterChildName): $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); $_nameAfterChild->setProduct($_product); ?> <?php echo $_nameAfterChild->toHtml(); ?> <?php endforeach; endif; ?> 

go line no 188

add code to

 if($this->getChild('after')): //code endif; 
+2
source

I have the error below: Fatal error: calling the getSortedChildren () member function for a non-object in C: \ wamp \ www \ magento1901 \ app \ design \ frontend \ rwd \ default \ template \ catalog \ product \ List.phtml in line 183

find this code

 <?php //set product collection on after blocks $_afterChildren = $this->getChild('after')->getSortedChildren(); foreach($_afterChildren as $_afterChildName): $_afterChild = $this->getChild('after')->getChild($_afterChildName); $_afterChild->setProductCollection($_productCollection); ?> <?php echo $_afterChild->toHtml(); ?> <?php endforeach; ?> 

replace the code with

 <?php if($this->getChild('after')): //set product collection on after blocks $_afterChildren = $this->getChild('after')->getSortedChildren(); foreach($_afterChildren as $_afterChildName): $_afterChild = $this->getChild('after')->getChild($_afterChildName); $_afterChild->setProductCollection($_productCollection); ?> <?php echo $_afterChild->toHtml(); ?> <?php endforeach; endif; ?> 
0
source

All Articles