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 
00033 $installer->getConnection()->addColumn(
00034     $installer->getTable('eav/attribute'),
00035     'used_in_product_listing',
00036     'tinyint(1) UNSIGNED NOT NULL DEFAULT 0'
00037 );
00038 $installer->getConnection()->addColumn(
00039     $installer->getTable('eav/attribute'),
00040     'used_for_sort_by',
00041     'tinyint(1) UNSIGNED NOT NULL DEFAULT 0'
00042 );
00043 
00044 $entityTypeId   = $installer->getEntityTypeId('catalog_product');
00045 $sqlAttributes  = $installer->getConnection()->quoteInto('?',
00046     Mage::getSingleton('catalog/config')->getProductCollectionAttributes()
00047 );
00048 $installer->run("
00049 UPDATE `{$installer->getTable('eav/attribute')}`
00050     SET `used_for_sort_by`='1'
00051     WHERE `entity_type_id`='{$entityTypeId}'
00052         AND `attribute_code` IN('name', 'price');
00053 UPDATE `{$installer->getTable('eav/attribute')}`
00054     SET `used_in_product_listing`='1'
00055     WHERE `entity_type_id`='{$entityTypeId}'
00056         AND `attribute_code` IN($sqlAttributes);
00057 ");
00058 
00059 $installer->getConnection()->addKey(
00060     $installer->getTable('eav/attribute'),
00061     'IDX_USED_FOR_SORT_BY',
00062     array('entity_type_id','used_for_sort_by')
00063 );
00064 $installer->getConnection()->addKey(
00065     $installer->getTable('eav/attribute'),
00066     'IDX_USED_IN_PRODUCT_LISTING',
00067     array('entity_type_id','used_in_product_listing')
00068 );
00069 
00070 
00071 $installer->getConnection()->addColumn(
00072     $installer->getTable('eav/attribute'),
00073     'frontend_input_renderer',
00074     'varchar(255) DEFAULT NULL AFTER `frontend_input`'
00075 );
00076 
00077 
00078 $entityTypeId     = $installer->getEntityTypeId('catalog_category');
00079 $attributeSetId   = $installer->getDefaultAttributeSetId($entityTypeId);
00080 $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
00081 
00082 
00083 $installer->updateAttributeGroup(
00084     $entityTypeId,
00085     $attributeSetId,
00086     $attributeGroupId,
00087     'attribute_group_name',
00088     'General Information'
00089 );
00090 $installer->updateAttributeGroup(
00091     $entityTypeId,
00092     $attributeSetId,
00093     $attributeGroupId,
00094     'sort_order',
00095     '10'
00096 );
00097 
00098 
00099 $groups = array(
00100     'display'   => array(
00101         'name'  => 'Display Settings',
00102         'sort'  => 20,
00103         'id'    => null
00104     ),
00105     'design'    => array(
00106         'name'  => 'Custom Design',
00107         'sort'  => 30,
00108         'id'    => null
00109     )
00110 );
00111 
00112 foreach ($groups as $k => $groupProp) {
00113     $installer->addAttributeGroup($entityTypeId, $attributeSetId, $groupProp['name'], $groupProp['sort']);
00114     $groups[$k]['id'] = $installer->getAttributeGroupId($entityTypeId, $attributeSetId, $groupProp['name']);
00115 }
00116 
00117 
00118 $installer->addAttribute($entityTypeId, 'available_sort_by', array(
00119     'input'         => 'multiselect',
00120     'type'          => 'text',
00121     'label'         => 'Available Product Listing Sort by',
00122     'source'        => 'catalog/category_attribute_source_sortby',
00123     'backend'       => 'catalog/category_attribute_backend_sortby',
00124     'required'      => 1,
00125     'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
00126     'visible'       => 1,
00127     'input_renderer'=> 'adminhtml/catalog_category_helper_sortby_available',
00128 ));
00129 $installer->addAttribute($entityTypeId, 'default_sort_by', array(
00130     'input'         => 'select',
00131     'label'         => 'Default Product Listing Sort by',
00132     'source'        => 'catalog/category_attribute_source_sortby',
00133     'backend'       => 'catalog/category_attribute_backend_sortby',
00134     'required'      => 1,
00135     'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
00136     'visible'       => 1,
00137     'input_renderer'=> 'adminhtml/catalog_category_helper_sortby_default',
00138 ));
00139 
00140 
00141 $attributes = array(
00142     'custom_design'         => array(
00143         'group' => 'design',
00144         'sort'  => 10
00145     ),
00146     'custom_design_apply'   => array(
00147         'group' => 'design',
00148         'sort'  => 20
00149     ),
00150     'custom_design_from'    => array(
00151         'group' => 'design',
00152         'sort'  => 30
00153     ),
00154     'custom_design_to'      => array(
00155         'group' => 'design',
00156         'sort'  => 40
00157     ),
00158     'page_layout'           => array(
00159         'group' => 'design',
00160         'sort'  => 50
00161     ),
00162     'custom_layout_update'  => array(
00163         'group' => 'design',
00164         'sort'  => 60
00165     ),
00166     'display_mode'          => array(
00167         'group' => 'display',
00168         'sort'  => 10
00169     ),
00170     'landing_page'          => array(
00171         'group' => 'display',
00172         'sort'  => 20
00173     ),
00174     'is_anchor'             => array(
00175         'group' => 'display',
00176         'sort'  => 30
00177     ),
00178     'available_sort_by'     => array(
00179         'group' => 'display',
00180         'sort'  => 40
00181     ),
00182     'default_sort_by'       => array(
00183         'group' => 'display',
00184         'sort'  => 50
00185     ),
00186 );
00187 
00188 foreach ($attributes as $attributeCode => $attributeProp) {
00189     $installer->addAttributeToGroup(
00190         $entityTypeId,
00191         $attributeSetId,
00192         $groups[$attributeProp['group']]['id'],
00193         $attributeCode,
00194         $attributeProp['sort']
00195     );
00196 }
00197 
00198 $installer->endSetup();