Dalam membuat custom attribute pada category, yang diperlukan adalah membuat beberapa file agar magento anda menjadi sangat rapi yaitu dengan membuatnya menjadi sebuah module.
adapun file yang perlu untuk dibuat antara lain:
- app\etc\modules\Novayadi_Customcategory.xml
- app\code\local\Novayadi\Customcategory\etc\config.xml
- app\code\local\Novayadi\Customcategory\Helper\Data.php
- app\code\local\Novayadi\Customcategory\sql\customcategory_setup\mysql4-install-0.1.0.php
Novayadi_Customcategory.xml
<?xml version="1.0"?>
<config>
<modules>
<Novayadi_Customcategory>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Novayadi_Customcategory>
</modules>
</config>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Novayadi_Customcategory>
<version>0.1.0</version>
</Novayadi_Customcategory>
</modules>
<global>
<helpers>
<customcategory>
<class>Novayadi_Customcategory_Helper</class>
</customcategory>
</helpers>
<models>
<customcategory>
<class>Novayadi_Customcategory_Model</class>
<resourceModel>customcategory_mysql4</resourceModel>
</customcategory>
</models>
<resources>
<customcategory_setup>
<setup>
<module>Novayadi_Customcategory</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customcategory_setup>
<customcategory_write>
<connection>
<use>core_write</use>
</connection>
</customcategory_write>
<customcategory_read>
<connection>
<use>core_read</use>
</connection>
</customcategory_read>
</resources>
</global>
</config>
Data.php
<!--?php <br ?-->class Novayadi_Customcategory_Helper_Data extends Mage_Core_Helper_Abstract
{
}
mysql4-install-0.1.0.php
<!--?php $installer = $this; $installer--->startSetup();
$installer->addAttribute("catalog_category", "videoembed", array(
"type" => "varchar",
"backend" => "",
"frontend" => "",
"label" => "Video Embed",
"input" => "text",
"class" => "",
"source" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
"visible" => true,
"required" => false,
"user_defined" => false,
"default" => "",
"searchable" => false,
"filterable" => false,
"comparable" => false,
"visible_on_front" => false,
"unique" => false,
"note" => "Masukkan url video "
));
$installer->endSetup();
Setelah membuat file-file tersebut di atas, silakan di clear cache dan kemudian di halaman category akan bertambah 1 field dengan “Video embed”…….
#Selamat mencoba#