I am writing here a small but useful snippet of code, for getting the table name of any module (whose table name are defined in config file). This is very useful when using joins in query. Suppose my module is ‘vendor’.
Tag: Model
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.
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 […]
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, kindly paste […]
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 […]
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 Hope this is helpful.
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 […]
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 […]
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 […]
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. […]