How to add text field after image for the category in catalog category tried to copy app/code/core/Mage/Catalog
folder to local code pool but not find out where to add a field.
-
you can create Category attribute to achieve your requirement. – Abhishek Panchal Sep 12 '17 at 13:19
-
you can download custom extension created for category attribute: drive.google.com/file/d/0B4PokeydRXWeaDEwTTRETExoMEk/… – Vinod Kumar Sep 13 '17 at 7:28
you can add new custom category attribute in your Magento store via sql_setup script.
MySQL setup script will look something like this, it depends on your needs and how you would like to configure your new attribute:
$installer = $this;
$installer->startSetup();
$entityTypeId = $installer->getEntityTypeId('catalog_category');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute('catalog_category', 'new_cat_attrb', array(
'type' => 'int',
'label' => 'New Category Attribute',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0
));
$installer->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'new_cat_attrb',
'11' //last Magento's attribute position in General tab is 10
);
$attributeId = $installer->getAttributeId($entityTypeId, 'new_cat_attrb');
$installer->run("
INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
FROM `{$installer->getTable('catalog_category_entity')}`;
");
//this will set data of your custom attribute for root category
Mage::getModel('catalog/category')
->load(1)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
//this will set data of your custom attribute for default category
Mage::getModel('catalog/category')
->load(2)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
$installer->endSetup();
In your config.xml file of your module you will need to add this part in order to install correctly your new category attribute:
<resources>
<new_attribute_csv_setup>
<setup>
<module>New_Attribute</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</new_attribute_setup>
<new_attribute_setup_write>
<connection>
<use>core_write</use>
</connection>
</new_attribute_setup_write>
<new_attribute_setup_read>
<connection>
<use>core_read</use>
</connection>
</new_attribute_setup_read>
</resources>
Pay attention on class tag here, class must be: Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
.
Reference link
You can see a new tab general tab in category form.
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("catalog_category", "testfield", array(
"type" => "int",
"backend" => "",
"frontend" => "",
"label" => "test",
"input" => "text",
"class" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
"visible" => true,
"required" => false,
"user_defined" => false,
"default" => "0",
"searchable" => false,
"filterable" => false,
"comparable" => false,
"visible_on_front" => false,
"unique" => false,
"note" => ""
));
$installer->endSetup();