5

I want to show two configurable products on a cms page. The two products are under a sub category (id = 343). I've used below code in my cms page:

{{block type="core/template" name="home.catalog.product.list" 
alias="products_homepage" category_id="343"  product_count="2" 
template="catalog/product/list.phtml"}}

but it gives this error:

Fatal error: Call to a member function count() on a non-object in /home2/hotelhome/public_html/app/design/frontend/default/sm_sport/template/catalog/product/list.phtml on line 38

0

Try to just use this

{{block  type="catalog/product_list" category_id="343"  template="catalog/product/list.phtml"}}

That should do the trick, you don´t need the product_count as it will just show all and if there are only 2 then that's it.

0

Try to use widget Magento\CatalogWidget\Block\Product\ProductsList

{{widget type="Magento\CatalogWidget\Block\Product\ProductsList" products_count="2" template="product/widget/content/grid.phtml" conditions_encoded="a:2:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]s:4:`1--1`;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Product`;s:9:`attribute`;s:12:`category_ids`;s:8:`operator`;s:2:`==`;s:5:`value`;s:1:`343`;]]"}}
0

I think maybe your type is wrong, try catalog/product_list? Or do you want to show the products individually?

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

Alternatively you could use XML on the CMS page?

<reference name="content">
    <block type="catalog/product_list" name="home" template="catalog/product/list.phtml">
        <!-- Product List View -->
        <action method="setCategoryId"><category_id>343</category_id></action>
        <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
            <block type="page/html_pager" name="product_list_toolbar_pager"/>
        </block>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
    ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.