Skip to main content

Posts

Send emails using cronjob in Magento

Hi All !! While working on one of my project client ask me to create a cronjob which send emails to customers. Firstly, I thought it might be difficult but it was so easy. In this post we will learn it. Suppose package name is 'MyPackage' and module name is 'MyModule. MyModule is in local directory. Following are the files on which we have to work: 1) app/code/local/MyPackage/MyModule/etc/config.xml 2) app/code/local/MyPackage/MyModule/etc/system.xml 3) app/code/local/MyPackage/MyModule/Model/Observer.php 4) app/locale/en_US/template/email/<custom_email_template> Step 1: 1) File Name:   app/code/local/MyPackage/MyModule/etc/config.xml Add below code inside config tag <config>  <crontab>     <jobs>         <your_cronjob_code>             <schedule>           ...

Change Admin Password using MySql query in magento

Hello friends, Sometimes we forgot admin password and then we are stuck. In that case we can change the admin password using below sql query. Before that we need to understand how the password is stored in magento. Magento stores admin password by concatenating two string: 1) one is randomly generated string having two alphabets one in capital letters and another in small letters like: aU, gE etc. 2) Password and the randomly generated string in MD5 format. For example if we want to use 'admin123' as password then string will be 'aUadmin123'. Magento concatenate both two strings and stores it. Admin details are stored in admin_user table so we have to use update query on admin_user table. Now we know about that how magento stores password it will be easy for us to create an update query. Update 'admin_user'  set password= CONCAT(MD5( 'aUadmin123') , ':aU') where username = 'admin'; That's all, now you can easily chang...

Add Products to cart Programmatically in Magento

Sometimes we need to add products into cart programmatically in controller. Below is the code which you can use to add product to cart.   1) For Simple Products If you are working in magento controller and wants to add a simple product programmatically then here is the code: Suppose our product id value stored in $productId.         // Below code will create instance of cart         $cart = Mage::getModel('checkout/cart');         // This will initialize cart         $cart->init();         // Get the product collection by passing product id         $productCollection = Mage::getModel('catalog/product')->load($productId); This product collection will be required as we have to pass it at the time of adding product to cart. For adding the product we...

Quick Order Placement Form

If we want to place fast and quick order. We want to list all the product along with their categories  and price. For achieving this goal we have to follow these steps: 1) Create Template File : Create a template  file at /app/design/frontend/default/blanco/template/catalog/product/list_fast_order.phtml which will the list of all products along with their categories and Price listing. 2) Edit Layout : Before this we have to add the phtml file in catalog.xml file. 3) Get Result :  In list_fast_order.phtml file we have to show the product category wise /*assume we want to get all products of category id 5 */ $catid_1 = 5; /*we are loading all the products from category id 5 */ $_category = Mage::getModel('catalog/category')->load($catid_1); $subs = $_category->getAllChildren(true); /* Use for loop for making result array */ $result = array(); foreach($subs as $cat_id) { $category = new Mage_Catalog_Model_...

Mobilize your Magento Store

In this post I will illustrate 'How you can mobilize your Magento Store' Browser's Settings : 1) First of all your browser must have iPhone user agent.        In Safari it has its own user agent, just go to Developer > User Agent  and set it to iPhone.        If you are using Firefox then go to Tools > Default User Agent and select iPhone. If you don't have iPhone in option then Tools > Add-ons and install 'User Agent Switcher 0.7.3 in firefox browser. This will switch your Site view from Desktop to Mobile.  Check you special user agent :  whatsmyuseragent.com At last you have your phone to test the Mobile Site. Magento Admin Settings: 1) Log-in to your Magento admin and go to System > Configuration > General > Design. 2) In Design open 'Themes' tab to Mobilize your Store.   3) In Templates click on Add Exception button and In Matched Expression set your ...