php - How to limit the products on homepage magento also show all properties? -
i using magento rwd theme.
i want limit number of products shown 4. want show things add cart button, reviews section , price.
currently tried , tested following code it's not working.
{{block type="catalog/product_list" name="product_list" category_id="19" mode="grid" template="catalog/product/list.phtml" column_count="4" limit="4" }}
how can done?
i attaching screenshot of output getting.
you can not set 'limit' catalog/product_list
block in such way.
the best place (please correct me if there better place/event) via event 'core_block_abstract_prepare_layout_before'.
this allow instantiate toolbar , change limit.
the code easy , straightforward. observer file,
class test_module_controller_router { public function homeproductcollection($observer) { try{ $block=$observer->getevent()->getblock(); if($block instanceof mage_catalog_block_product_list){ if($block->getproductlimit()){ $toolbar=$block->gettoolbarblock(); $block->settoolbarblockname($toolbar->getnameinlayout()); $toolbar->setdata('_current_limit',$block->getproductlimit()); } } }catch (exception $e){ mage::logexception($e); } return $this; } }
your xml file,
<config> ... <global> ... <events> <core_block_abstract_prepare_layout_before> <observers> <test_module> <class>test_module_controller_router</class> <method>homeproductcollection</method> </test_module> </observers> </core_block_abstract_prepare_layout_before> </events> ... </global> ... </config>
the cms block used create this:
{{block type="catalog/product_list" category_id="3" product_limit="2" template="catalog/product/list.phtml"}}
for more information check here
Comments
Post a Comment