Magento E-commerce Platform Q/ A

How to Automatically Convert Simple Products to Bundle in Magento

The feature might be useful for the stores dealing with large and often updated inventory. In order not to convert each product manually after each inventory update to existing bundle products it is possible to make the process automated.

First we will create the observer that will be performing the function each time a new product is saved.

Announce the observer in config.xml file:

Creating Recursive Menu in Magento

In order to create the menu a function need to be added. The function that will receive the ID of the parent (main) categories as an argument and will be displaying child categories. Also the function should check presence of the sub-categories each time a child category is called.  

Here's the example of the 'recursive' function:

How to Add a Custom Table to Magento Admin Backend

In this article we will add a custom table to Magento admin interface. The table that will be displaying information from  the data base table: sales_flat_order_item.

238

Namespace - Ikantam

Module - KnowledgeBase

In the configuration file of the module we will create new item 'Order Items'

239

/app/code/local/Ikantam/KnowledgeBase/etc/config.xml

Custom Redirect from a Category Page in Magento

Let's assume your customer needs to redirect store users when they click on some category link to some particular product page. You can do it by creating a simple module. 

The structure of the etc/config.xml file:

How to Add a New Tab to a Category in Magento

To add a new magento category tab (manage categories page/ admin area), rewrite or simply copy the file from: core/Mage/Adminhtml/Block/Catalog/Category/Tabs.php to: local/Mage/Adminhtml/Block/Catalog/Category/Tabs.php.

Next in _prepareLayout method after this code:

$this->addTab(’products’, array( 
‘label’ => Mage::helper(’catalog’)->__(’Category Products’), 
‘content’ => $this->getLayout()->createBlock(’adminhtml/catalog_category_tab_product’, ‘category.product.grid’)->toHtml(), 
));

 

Add this one:

How to Add Custom Renderer to Magento Grid

Magento Grid – a very handy tool for flexible data display. In Magento it is usually  presented as a table. There is a possibility to modify tables if necessary.

To do this, you need to add a column to Magento grid and overwrite the default renderer with a custom one.

In the example below, instead of product id we will be displaying product image in 'Product' id column.  You can see default meaning of the column (before customization):

235

Use this code to add a custom renderer:

Custom Product Sorting Options in Magento

Frequently due to the variety of products available in the catalog it is necessary to add additional sorting options such as sort by brand or color. This is the example of how to add different sorting options to the products. In the below example sorting by products position depending on manufacturer attribute on the category page is shown.

Magento Product Ratings and Reviews

There is prebuilt product ratings and reviews functionality in Magento. By default all reviews and ratings should be approved by the store owner via Magento admin panel.

Store users can rate (review) products by clicking the link on the product page.

214

 

At the product page users see the form to leave a comment to the product and rate it by assigning it 1-5 star rating.

215

 

 

Magento Source Model

Source model serves to insert the data into the certain fields: checkboxes, multi selects, radios, selects in admin area: System- > Configuration.

 

To indicate Source Model for the field, add tag: <source_model> and define source model in it

<source_model>adminhtml/system_config_source_allregion</source_model>

The field must contain tag: <frontend_type> with one of the values: сheckbox, multi select, radio or select.

 

Magento Models

The access to the data in the database works via models. There is no universal definition for models as there are a number of different model types, each of the type is responsible for a certain part of the module.