Retrieve current product, category and CMS page Magento Registry

Sunday, 13. November 2011

Here are the quick snippet scripts for pulling out the current product, category and cms page from inside script or template files in Magento.

Get Current category

$_category = Mage::registry('current_category');

Get Current Product

$_product = Mage::registry('current_product');

Get Gurrent CMS Page

$_cmspage = Mage::registry('cms_page')


Show All Category Products By Default In Magento Programatically

Thursday, 28. July 2011

In order to show all products in a category by default you can follow this approach:

1) Overwrite the Core toolbar class: Mage_Catalog_Block_Product_List_Toolbar.php

2) From the base class, copy and override the function getLimit() in your new class. (method starts around line 723)

3) In your overridden function, Look for a line:

$limit = Mage::getSingleton('catalog/session')->getLimitPage();

And replace it with

$limit = 'all';

You can now clear your Magento cache in order to register your new extension and have fun testing your view all products on a category page by default!