Thursday, October 25, 2012

How to add custom product type in Magento

>> Basically You can't create a product type from Admin. You need to modify config.xml and sql in your module.


                <classified translate="label" module="vendor">

Here classified is my custom product type and vendor is my custom module.

Now you need to update price type attributes for new type : To run your sql file of your module for next time you need to delete the row created for the module "vendor" in core_resource table. We will discuss later for update Sql.

$installer = $this;
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */


$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$fieldList = array(

// make these attributes applicable to downloadable products
foreach ($fieldList as $field) {
    $applyTo = split(',', $setup->getAttribute('catalog_product', $field, 'apply_to'));
    if (!in_array('classified', $applyTo)) {
        $applyTo[] = 'classified';
        $setup->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));