Get The Current Category
Mage::registry('current_category');
Related cards:
Get Methods of Class
Yes, very dirty, but it works a treat! Save this file in your Magento root directory, then fire up a command line and run whatever.php Mage_Core_Model_App
(or some other class) and you should see the output.
Output looks like below:
$ ./cl...
Getting the Theme In Use
How to get the theme for each component, works on the active store:
Mage::getSingleton('core/design_package')->getTheme('locale');
Mage::getSingleton('core/design_package')->getTheme('template');
Mage::getSingleton('core/design_packag...
Get and Resize Category Images
public function getCategoryImage(Mage_Catalog_Model_Category $category, $width = 250, $height = 250)
{
// return when no image exists
if (!$category->getImage()) {
return false;
}
// return when...
Get Category Children
public function getCategories()
{
if (!$this->categories) {
$categoryId = $this->getData('parent_category_id');
$parentCategory = Mage::getModel('catalog/category')->load($categoryId);
$categor...
Getting A Products URL
Potentially confusing due to the 3 methods you could use, all of which are in Mage_Catalog_Model_Product
:
public function getUrlPath($category=null)
public function getUrlInStore($params = array())
public function getProductUrl($use...
Getting The Amount Of Items in the Cart
To get the amount of line items (i.e. 10 of 1 product is 1):
Mage::helper('checkout/cart')->getItemsCount();
To get the total number of items (i.e. 10 of 1 product is 10):
Mage::helper('checkout/cart')->getSummaryCount();
![](http://mi...
Getting The Last Order ID From The Session
Mage::getSingleton('checkout/session')->getLastOrderId();
Many to Many Resource Model Mapping
This is some boilerplate code to facilitate the use of many-to-many relationship tables in Magento. I found myself rewriting this code often, so this saves some time. This example links a sizeguide entity to attribute sets. Obviously you'll need t...
Changing The Admin Theme
Put this in your local.xml
:
<config>
<stores>
<admin>
<design>
<theme>
<default>yourtheme</default>
</theme>
</design>
...