Jan 6, 2012
Website ID from Store Group ID in Magento
Hello All,
I am posting here code for fetching website information from Store Group Id.
Also useful code showing relations between Stores, Groups and Websites.
< ?php
$store_id = 1; //your required store Id will go here
$store_model = Mage::getModel('core/store'); //store model
$store_group_model = Mage::getModel('core/store_group'); //store group model
$website_model = Mage::getModel('core/website');...
read more
Dec 14, 2011
Ajax in Magento
There are some instances when we are required to use Ajax features in Magento.
Prototype javascript library used in Magento has inbuilt functionality for Ajax.
I am describing here the basic method to use ajax.
I have used version 1.6.0.0 of Magento.
I am using the existing Contacts module for explanation, you can make any new module or use any of your local module.
This code will generate the hash...
read more
Nov 28, 2011
Root Category in Magento
In Magento, products are assigned to Website, though we can disable the product in independent store, but this is very lengthy procedure as you need to edit each and every products.
So I came up with the solution to restrict the display of categories and products, though if you assign different Root Catalog to different store, Magento will display the categories as per the stores but not products as...
read more
Nov 11, 2011
Order Profit column in Magento
I am explaining here the way to add a Profit column in Order grid seen in admin-end
This column will show the profit gained per order (i.e, the difference between Cost and Selling Price)
1) Copy the app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php file to app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php, by maintaining the directory structure
2) There is a protected function _prepareColumns,...
read more
Nov 7, 2011
Custom Email Templates in Magento
Hello,
I am explaining here the method for sending custom emails using the custom email templates with variables.
1) Create an email template from Admin-end > System > Transactional Emails, for example lets put this as Template Content
<!--@vars
{
"htmlescape var=$customer.name":"Customer Name",
"var customer.email":"Customer Email"
}
@-->
Dear {{htmlescape...
read more
Oct 13, 2011
Empty Cart in Magento
In one of my project, I needed to explicity delete the items from cart after order placed.
You can also use this script for making a functionlity for giving an option for empting the cart at once from cart page.
Here is the script for the same. Place it in function ‘successAction’ in app\code\local\Mage\Checkout\controllers\OnepageController.php (copy this file from app\code\core\Mage\Checkout\controllers\OnepageController.php)
/**
...
read more
Sep 12, 2011
Grid filters in Magento
Since last few days I am working on a custom admin module, and was required to make a functionality related to Filters.
The functionality was such that I needed to fetch the filters inserted in the Grid, that is if we are searching records with names like ‘john’, so here ‘john’ will be filter.
Now it was bit confusing here, Magento encodes (base64_encode) the filter inserted,...
read more
Aug 24, 2011
Country and States in Magento
Hello All,
Magento has inbuilt model for Country and State as seen in Checkout page.
In checkout page if you select Country like ‘France’ , a drop down will be seen in place of textbox for States.
I am writing here the code to directly get country name from ID and also to get States info from country.
<?php
$countryName = Mage::getModel('directory/country')->load('FR')->getName();...
read more
Aug 12, 2011
Disable ‘Billing Agreements’ and ‘Recurring Profiles’ in Magento
Hello All ,
From the new functionalities introduced from Magento 1.4.1.0 , two are ‘Billing Agreements’ and ‘Recurring Profiles’
Sad thing is that this cannot be disabled from admin completly.
For hiding the links from the navigation in ‘My Account’ section of Customer, you can copy billing_agreement.xml and recurring_profile.xml from /app/design/frontend/base/default/layout/sales/...
read more
Aug 4, 2011
Email Addresses in Magento
In Magento in adminend (Adminend > System > Configuration > Store Email Addresses) we have a section for storing various store email addresses used in sections like Orders,Sales etc
Sometime need arises to get the values of these fields in our custom script
I am writing here the script to get these values
<?php
//General Contact
echo $name = Mage::getStoreConfig('trans_email/ident_general/name');...
read more
