2014-06-04 45 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; 
?> 
相關問題