Magento Themes and Magento Extensions

Magento – Get Category Id from Product

Posted on April 29th, 2013 | Posted by admin

Magento - Get Category Id from Product

$items = Mage::getSingleton(‘checkout/session’)->getQuote()->getAllItems();

foreach($items as $item)
$categoryIds = $item->getProduct()->getCategoryIds(); // returns category ids from product

Access Magento User’s Session From Outside Magento?

Posted on April 6th, 2013 | Posted by admin

Im trying to access the Magento customer session in another part of my website. <- Magento

The shop itself works like a charm, however im trying to determine within test.php if a customer is logged in, so I can display his name with a link to his cart.

Contents of test.php so far:

require_once dirname(__FILE__).’/shop/app/Mage.php’;
Mage::getSingleton(‘core/session’, array(‘name’ => ‘frontend’));

I keep getting bool(false) returned. I’m logged into Magento at so true is expected.

Magento: Get the list of events from magento

Posted on March 19th, 2013 | Posted by admin

Magento: Get the list of events from magento

Use following code in action of magento
$eventAreas = array(‘global’,'frontend’,'adminhtml’);
foreach ($eventAreas as $eventArea) {
$eventConfig = Mage::app()->getConfig()
->getNode(sprintf(‘%s/events’, $eventArea));
foreach($eventConfig->children() as $key=>$value)
foreach($value->observers->children() as $key1=>$value1)

Creating Block from controller in Magento

Posted on December 25th, 2012 | Posted by admin

There are two types of blocks can be created in Magento

a) Structural Block: This block usually contains the attribute ‘as’ with block tag through which the application will communicate with designated area.

b) Content Block: These are the blocks that produces actual content inside each structural block. It seems like normal template file that are used to show particular data on the page.

Most of the time a programmer needs to create a structural block and need to show it into the content area of the page. Here are the code you need to write for it.