2014-06-04 65 views
1

我想在主页上显示类别及其产品。 Magento已经内置了在主页上显示新产品的选项,我不知道如何在主页上显示不同的类别。例如,我创建了一个类别,我想表明的这一类产品在主页上,如下面:在主页上显示类别及其产品,Magento1.9

特色产品

产品1 产品2 产品3

我曾尝试下面的代码(从以前的帖子)

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

但是这给了我下面的错误

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 

显然我上面提到的代码是针对以前的版本或Magento。但是版本1.9.0.1会给出错误。

请指导如何在主页上显示类别。由于

+0

凯撒替换代码,我在链接http://stackoverflow.com/questions/21241181/cms-page-with-layered-navigation-not-working/解释这种类型的任务21242296#21242296 –

+0

嗨艾米特你以前的帖子不帮我。你能否再次检查我编辑的问题,并建议我该怎么做。 – Kaiser

+0

嗨kaiser,这是固定的 –

回答

2

for new product list in magento 1.9 use this one

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

enter image description here 或类别明智的房源

新RWD设计对产品列表中两个子块。 more info

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

你可以先打电话给你块CMS主页象下面这样:

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

现在在你的目录/产品/ list.phtml发现号线74:133

发现这代码

<?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; ?> 

取代
<?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; 
?> 

走线无188

附加代码到

if($this->getChild('after')): 

//code 

endif; 
+0

嗨拉维我已经尝试过上述方法。它确实在主页上显示该类别的产品,但主页滑块和其他产品已消失,并且出现以下错误:致命错误:调用C:\ wamp \ www \ magento1901中的非对象上的成员函数getSortedChildren() \ app \ design \ frontend \ rwd \ default \ template \ catalog \ product \ list.phtml on line 183 – Kaiser

+0

检查您的条件,我可以在我的答案中添加。 –

0

我有一个如下错误:致命错误:调用一个成员函数getSortedChildren()一个非对象在C:\ WAMP \ WWW \ magento1901 \程序\设计\前台\ RWD \ DEFAULT \模板\目录\产品\上线183

list.phtml找到这段代码

<?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; ?> 

<?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; 
?> 
相关问题