00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 $installer = $this;
00028
00029
00030 $installer->startSetup();
00031
00032 $installer->run("
00033
00034 DROP TABLE IF EXISTS {$this->getTable('catalog_product_bundle_option')};
00035 CREATE TABLE {$this->getTable('catalog_product_bundle_option')} (
00036 `option_id` int(10) unsigned NOT NULL auto_increment,
00037 `parent_id` int(10) unsigned NOT NULL,
00038 `required` tinyint(1) unsigned NOT NULL default '0',
00039 `position` int(10) unsigned NOT NULL default '0',
00040 `type` varchar(255) NOT NULL default '',
00041 PRIMARY KEY (`option_id`)
00042 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bundle Options';
00043
00044 DROP TABLE IF EXISTS {$this->getTable('catalog_product_bundle_option_link')};
00045 DROP TABLE IF EXISTS {$this->getTable('catalog_product_bundle_selection')};
00046 CREATE TABLE {$this->getTable('catalog_product_bundle_selection')} (
00047 `selection_id` int(10) unsigned NOT NULL auto_increment,
00048 `option_id` int(10) unsigned NOT NULL,
00049 `product_id` int(10) unsigned NOT NULL,
00050 `position` int(10) unsigned NOT NULL default '0',
00051 `is_default` tinyint(1) unsigned NOT NULL default '0',
00052 `selection_price_type` tinyint(1) unsigned NOT NULL default '0',
00053 `selection_price_value` decimal(12,4) NOT NULL default '0.0000',
00054 `selection_qty` decimal(12,4) NOT NULL default '0.0000',
00055 `selection_can_change_qty` tinyint(1) NOT NULL default '0',
00056 PRIMARY KEY (`selection_id`)
00057 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bundle Selections';
00058
00059 DROP TABLE IF EXISTS {$this->getTable('catalog_product_bundle_option_value')};
00060 CREATE TABLE {$this->getTable('catalog_product_bundle_option_value')} (
00061 `value_id` int(10) unsigned NOT NULL auto_increment,
00062 `option_id` int(10) unsigned NOT NULL,
00063 `store_id` smallint(5) unsigned NOT NULL,
00064 `title` varchar(255) NOT NULL default '',
00065 PRIMARY KEY (`value_id`)
00066 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bundle Selections';
00067
00068 ");
00069
00070 $installer->addAttribute('catalog_product', 'price_type', array(
00071 'type' => 'int',
00072 'backend' => '',
00073 'frontend' => '',
00074 'label' => '',
00075 'input' => '',
00076 'class' => '',
00077 'source' => '',
00078 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
00079 'visible' => false,
00080 'required' => true,
00081 'user_defined' => false,
00082 'default' => '',
00083 'searchable' => false,
00084 'filterable' => false,
00085 'comparable' => false,
00086 'visible_on_front' => false,
00087 'unique' => false,
00088 'apply_to' => 'bundle',
00089 'is_configurable' => false
00090 ));
00091
00092 $installer->addAttribute('catalog_product', 'sku_type', array(
00093 'type' => 'int',
00094 'backend' => '',
00095 'frontend' => '',
00096 'label' => '',
00097 'input' => '',
00098 'class' => '',
00099 'source' => '',
00100 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
00101 'visible' => false,
00102 'required' => true,
00103 'user_defined' => false,
00104 'default' => '',
00105 'searchable' => false,
00106 'filterable' => false,
00107 'comparable' => false,
00108 'visible_on_front' => false,
00109 'unique' => false,
00110 'apply_to' => 'bundle',
00111 'is_configurable' => false
00112 ));
00113
00114 $installer->addAttribute('catalog_product', 'weight_type', array(
00115 'type' => 'int',
00116 'backend' => '',
00117 'frontend' => '',
00118 'label' => '',
00119 'input' => '',
00120 'class' => '',
00121 'source' => '',
00122 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
00123 'visible' => false,
00124 'required' => true,
00125 'user_defined' => false,
00126 'default' => '',
00127 'searchable' => false,
00128 'filterable' => false,
00129 'comparable' => false,
00130 'visible_on_front' => false,
00131 'unique' => false,
00132 'apply_to' => 'bundle',
00133 'is_configurable' => false
00134 ));
00135
00136 $installer->addAttribute('catalog_product', 'price_view', array(
00137 'group' => 'Prices',
00138 'type' => 'int',
00139 'backend' => '',
00140 'frontend' => '',
00141 'label' => 'Price View',
00142 'input' => 'select',
00143 'class' => '',
00144 'source' => 'bundle/product_attribute_source_price_view',
00145 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
00146 'visible' => true,
00147 'required' => true,
00148 'user_defined' => false,
00149 'default' => '',
00150 'searchable' => false,
00151 'filterable' => false,
00152 'comparable' => false,
00153 'visible_on_front' => false,
00154 'unique' => false,
00155 'apply_to' => 'bundle',
00156 'is_configurable' => false
00157 ));
00158
00159 $fieldList = array('price','special_price','special_from_date','special_to_date',
00160 'minimal_price','cost','tier_price','weight','tax_class_id');
00161 foreach ($fieldList as $field) {
00162 $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
00163 if (!in_array('bundle', $applyTo)) {
00164 $applyTo[] = 'bundle';
00165 $installer->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));
00166 }
00167 }
00168
00169 $installer->endSetup();