Magento themes and extensions

Magento adding downloadable product to cart by coding php

Posted on December 6th, 2012 | Posted by admin

Probably you know it’s possible to add a product to the cart via querystring, but may be you prefer code a new module for your needs using Magento objects and methods.

So adding a simple product is easy:

03.$cart = Mage::getSingleton('checkout/cart');
05.// start adding the product
07.try {
09.$cart->addProduct($product, array('qty' => 1));
11.// save the cart
15.$result = null;
17.} catch (Mage_Core_Exception $e) {
19.$result = $e->getMessage();

But how to add a Downloadable product with its right link ? Just try this, it’s a controller I used to integrate an “add to cart” API:

Magento – Get loaded class into magento

Posted on December 5th, 2012 | Posted by admin

Magento - Get loaded class into magento

if you are working with  .phtml  files and you want to know which class is getting loaded for this

then you can use the below codes in your .phtml file




echo Zend_Debug::dump($this);

How to display additional attributes in layered navigation in magento

Posted on December 4th, 2012 | Posted by admin

How to display additional attributes in layered navigation in magento

This is the simple way to display additional attributes of products in layered navigation which helps to filter product easily.

Following are the steps to dislay additional attributes in layered navigation.

1) To add new attribute which you want to display in layered navigation

Go to catalog>attribute>manage attribute
click on add new attribute
now you can create attribute as your required name.But some fields are required as

How to add Magento blocks, CSS and Javascript to an external site

Posted on December 3rd, 2012 | Posted by admin

You might have a Magento based website running online and wanted to extend parts of it (also known as blocks, which may include some css and js in the code) to an external site which may either be a blog, another CMS or any other PHP based web application. If you have been following my previous posts, you will know that by adding the Mage.php file of your Magento instance to your application, you can actually pull the needed HTML blocks at any time. The only problem is that most of the examples available online asks you to use thegetChildHtml(‘your-block-here’) in which most the time frustrates you because of its complexity and limited resources of how you can actually use it.

There are other ways of doing it. Oddly enough, some are pretty simple and straight forward.

We will use a single HTML file which will serve as our ‘external’ site. The source code of our index.php is shown below:

Magento products by categories

Posted on December 2nd, 2012 | Posted by admin

Does anyone know how I can get a list of products belonging to a specific category from within a view file in Magento?

It all depends on which view you’re in. ;

First off, I hope you stayed within your template set (default in my example).

Use this as an example:

$_cat         = $this->getCurrentCategory();
$_parent      = $_cat->getParentCategory();
$_categories  = $_parent->getChildren();

/* @var $category Mage_Catalog_Model_Category */
$collection = Mage::getModel('catalog/category')->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */