search
top

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

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

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()...
read more

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

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

Select Box in Magento

Hello All, I am listing here a useful topic related to Magento. Below is the description to generate a select box using inbuilt functions of Magento. Lets take an example of displaying a select box containing all the catalog products. I am using the existing core files for better understanding, you are recommended make new module or override existing files Lets use helper file of Catalog, app/code/core/Mage/Catalog/Helper/Data.php Paste...
read more

Filters in Query in Magento

Hello All, When we are filtering data in Magento, time occurs when we want to fetch result after filters like Not equal, greater than, less than, etc. The addFieldToFilter method’s second parameter is used for this. It supports an alternate syntax where, instead of passing in a string, you pass in a single element Array. The key of this array is the type of comparison you want to make. The value...
read more

Get cart products in Magento

Hello All, I am writing here a script for getting all the product’s id added into cart <?php $product_ids = Mage::getModel('checkout/cart')->getProductIds(); //get cart product ids print_r($product_ids); ?> Hope this is useful
read more

Get Products categories in Magento

Hello All, I am writing here the script to get category ids , for the given product. <?php $product_model = Mage::getModel('catalog/product'); //get product model $all_cats = array(); $product_model->reset(); $_product = $product_model->load($product_id); // $product_id is the given product id $all_cats = $product_model->getCategoryIds($_product); // all the...
read more

Category Name Magento

Hello all, I am writing here the code for getting category information of the known category id. <?php $catagory_model = Mage::getModel('catalog/category'); $categories = $catagory_model->load($id); // where $id will be the known category id if(!empty($categories)) { echo 'category name->'.$categories->getName(); //get category name echo 'category image...
read more

« Previous Entries Next Entries »

top