Currently Browsing: Magento
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 18, 2011
Product Quantity in Magento
For one of my project I needed to display the total quantities ordered in Products lifetime in product view page.
Here is the code
$product_id = 1; // the id of the product for which the quantities is required
$current_storeid = Mage::app()->getStore()->getId();//get current store id, used for filtering the collection
$productCollection = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect(array('name'))
->addAttributeToFilter('entity_id',array('eq',...
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
Jul 31, 2011
Customer Groups in Magento
Hello All,
I am writing here a script for displaying a select box of customers group.
There exists a Helper file for Customer at app/code/core/Mage/Customer/Helper/Data.php .
We need to extend this class for using the default function
Create a sample module inside local
I have used the Namespace ‘Decryptweb’ for my custom module.
For custom module you need to add a file in etc/modules/Decryptweb_Customer.xml
The...
read more
Jul 17, 2011
Generate CSV file in Magento
Hello All,
You might have seen that Magento provides a functionality to directly export the content from the grids in most of the modules seen in admin end like Sales, Products etc in the form of CSV or XML.
Sometimes the need arises to generate a CSV with the custom data.
Magento has already a nice class for it, it can be found at lib/Varien/File file name Csv.php. This class can be used...
read more
