search
top
Currently Browsing: Magento

Catalog Product Model

While working in Magento, you might have seen that there are various model defined like sales,catalog etc. I am writing here a script for working with catalog product model. <?php $model = Mage::getModel('catalog/product') //get product model //get product collection $collection = $model->getCollection() ->addStoreFilter() //store filter ->addAttributeToSelect('*')...
read more

Mail in Magento

While working in Magento eCommerce, many times need arises to send mail from within custom modules. Magento is based on Zend, Zend has a class defined for doing this. I am listing here the method for sending mail. <?php $to_email = ‘test@test.com’; $to_name = ‘to name’; $subject = ‘Mail Testing’; $Body = “Sending mail from magento”; $sender_email = “sender@sender.com”; $sender_name...
read more

Get Product ID and Product Name in Magento

In Magento eCommerce while working with catalog model, There arise the need to fetch product details from product id. We can get all product details if we have product id. But sometimes we only have product name, so we need to get product id for getting product details. I am listing here both the method. 1) Product details from Product ID. <?php $model = Mage::getModel('catalog/product') //getting...
read more

Develop,Package and Install Magento Module/Extension

This is very useful for those who are working in Magento eCommerce. After making an module (I will post the method to develop a module within few days). You can also refer this link for time being Develop Custom Magento Module for creating module. You have to package the module after developing which is explained here Package Module. Now obviously you want to test it. So I am writing the steps to...
read more

Queries in Magento

I am describing here the method for executing custom MySQL queries in Magento. <?php //select query $read = Mage::getSingleton('core/resource')->getConnection('core_read'); //make connection $qry = "select name FROM user_data WHERE id=1 LIMIT 1 "; //query $res = $read->fetchRow($qry); //fetch row $name = $res['name']; //outputs name //other form $qry =...
read more

Blocks in Magento eCommerce

If you are using Magento Ecommerce, you might have created ‘Static Blocks’ for integrating custom functionality. I am listing here the method to create CMS Blocks. Suppose you want a custom box to be displayed on right column. 1) Go to admin section there is menu ‘Static Blocks’ in ‘CMS’. 2) Click ‘Add New Block’. 3) Fill in the fields For example, Block...
read more

Magento Essentials

I am listing below important variable used in Magento. <?php echo Mage::app()->getFrontController()->getRequest()->getHttpHost(); //displays host name echo Mage::getBaseDir(); //gives physical path of the sites root directory echo $this->getSkinURL(); //gives relative path of the sites default skin folder echo Mage::getBaseURL(); //gives relative path of the site echo Mage::getURL();...
read more

Connect different database from Magento

Some of you might have worked on Magento. I am listing here points for connecting another database from Magento. 1) Suppose your database for Magento Project is named ‘magento’. 2) There is one other database named ‘wp’. 3) For using this database inside Magento, you need to setup connection in ‘config.xml’ file which resides in ‘urmagentodirectory/app/etc’ 4) In ‘config.xml’ there...
read more

top