How to create custom module in magento

Magento
Magento is best eCommerce system now a days which is offering rich customization possibilities by extensions and modules. Magento is built on a fully modular model that influences an unlimited scalability and flexibility for your store. Make Custom Module Magento There are many things custom modules can do, from editing your Database, to handling module upgrades to overriding classes (Blocks, Controllers, Models) ... and more! Magento is an open source solution. So you can write new modules for Magento by yourself. Here I want to show you how to create simple costume module magento. In Magento all modules are organized under a package. This package is nothing but a simple folder under codepool containing different modules. For example all core modules of magento system is kept under package "Mage" (open…
Read More

Excute custom query in magento

Magento
Magento has provide us very good features for handling or interacting with Database tables. Magento give all the data by default but some time we need to get or insert some custom data.So for this we need to write custom query. Database Connections In Magento [php] <?php // fetch read database connection that is used in Mage_Core module $read= Mage::getSingleton('core/resource')->getConnection('core_read'); // fetch write database connection that is used in Mage_Core module $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?> [/php] How to excute custom query in magento [php] <?php // fetch read database connection that is used in Mage_Core module $read= Mage::getSingleton('core/resource')->getConnection('core_read'); $value=$read->query("SELECT ...."); $row = $value->fetch(); echo "<pre>";print_r($row);echo "</pre>"; // As Array ?> [/php] Insert custom data in magento tabel [php] <?php // fetch write database connection that is used in Mage_Core module…
Read More

Add New Field to Magento Contact Form

Magento
In magento default contact us form provide only four fileds information like Name, Email, Telephone and comment but some time need to more information for contact form it's depends on bussiness model and criteria. If you want to add new field or need more inforation about the user from contact us so this artical to be helpfull to you. Below are the step how to add new field in magento contact us form. This example to show you how to add extra input type field in magento contact us form. Step 1: Add field to phtml file Go to app -> design -> frontend -> yourpackage -> yourtheme -> template -> contacts -> form.phtml If you want to add required field: [sourcecode language="plain"] <li> <label for="email"><em>*</em><?php echo Mage::helper('contacts')->__('Company Name') ?></label>…
Read More

Please check for sufficient write file permissions in magento connect manager

Magento
If you want to use install any other magento extension or upgrade your mangeto from magento connect manager its really very easy to do that. You can find really some great extensions some are paid and some are free from magento commerce site.Find extension that interest you, click "Get extension key", agree with license agreement and get key. But some times you want use magento connect manager and its display error like "Please check for sufficient write file permissions". Magento Connect requires write permissions to the Magento files in order to install new extensions or upgrade the software to a new version. You can change your file/folder permissions either thru your FTP Client (like FileZilla) OR thru a SSH client (like Putty). Go inside your Magento folder & change permissions…
Read More

How to get Magento layout outside of Magento

Magento
Get Magento Content Outiside of Magento I integreated wordpress in my magento store and I will try to get magento data in wordpress file. I want to same header in my both site magento and wordpress. I tryed to hard and finally got the solution to get any magento layout in wordpress. Below are the script to get magento layout outside of magento. [php] <?php require_once '/home/.../public_html/.../app/Mage.php'; umask(0); /* not Mage::run(); */ Mage::app('default'); // get layout object $layout = Mage::getSingleton('core/layout'); //get block object $block = $layout->createBlock('page/template_links'); /* choose whatever category ID you want */ //$block->setCategoryId(3); $block->setTemplate('page/template/links.phtml'); echo $block->renderView(); ?> [/php] Get Magento layout outside of Magento Below script to get whole magento header section with top links out side of magento. [php] <?php require_once '/home/.../public_html/.../app/Mage.php'; umask(0); /* not Mage::run(); */…
Read More

Display sub categories on main category page+Magento

Magento
display sub-categories instead of products on main category page+magento If you want to display Sub Categories list on main category or parent category in magento. So this artical may be help ful to you for design and display subcategories on parent category page+magento. => Copy the Category.php file from core to local. Create any directories required under app/code/local. (This is so images can be displayed) [sourcecode language="plain"] $ cp app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php app/code/local/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php [/sourcecode] => Add -addAttrbuteToSelect('image') to getChildrenCategories function [sourcecode language="plain"] public function getChildrenCategories($category) { $collection = $category->getCollection(); /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */ $collection->addAttributeToSelect('url_key') ->addAttributeToSelect('name') ->addAttributeToSelect('image') ->addAttributeToSelect('all_children') ->addAttributeToSelect('is_anchor') ->addAttributeToFilter('is_active', 1) ->addIdFilter($category->getChildren()) ->setOrder('position', 'ASC') ->joinUrlRewrite() ->load(); return $collection; } [/sourcecode] => Add or modify the category view template app/design/frontend/yourdiractory_path/default/template/catalog/category/view.phtml [php] <?php $_category = $this->getCurrentCategory(); $collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id); $rootcat = $_category->entity_id; $cat =…
Read More

How to call static block in magento

Magento
What is static block in magento? Static blocks can be used throughout your theme wherever you want to make small updates to a section of a page. Typical uses would be for promotional banners/callouts in sidebars or for some custom text in the middle of your home page. Static blocks can also be inserted into CMS pages or included in category pages. Creating s static block => Login in into your magento admin panel. => Navigate to CMS->Static blocks => Click Add new block => Give your block title (Title: A descriptive name to identify this block) => Give your block identifier (Identifier: The identifer will allow you to call this block from your template files or using the Magento markup tags. Typically this would be programmer friendly name with…
Read More

How to get Current page url in magento.

Magento
Get Current page url in magento or you can find catalog url using below code. With the help of this code you can easily find current page url in magento [php] <?php $current_page = ''; /* * Check to see if its a CMS page * if it is then get the page identifier */ if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'): $current_page = Mage::getSingleton('cms/page')->getIdentifier(); endif; /* * If its not CMS page, then just get the route name */ if(empty($current_page)): $current_page = Mage::app()->getFrontController()->getRequest()->getRouteName(); endif; /* * What if its a catalog page? * Then we can get the category path :) */ /* * Or you can check all values * $current_page_array = Mage::registry('current_category'); * $current_page_array['url_path'] */ if($current_page == 'catalog'): $current_page = 'path-' . preg_replace('#[^a-z0-9]+#', '-', strtolower(Mage::registry('current_category')->getUrlPath())); endif; ?> [/php] Also if you…
Read More

Check home page URL in magento

Magento
Check current page is home page in magento If you want to check current page is home page or not in magneto below code is helpful to you. [php] <?php if( Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ?> [/php] The other way you can check current page is home page or not in magento [php] <?php if($this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))): echo "Homepage"; else: echo "Not in Homepage"; endif; ?> [/php] [JWD-Magento-Development]
Read More