0
votes

I am creating module in magento 1.9.1, to create a attribute for categories. I have created files as follows:

app\etc\modules\Ddevs_Ebayaff.xml

<?xml version="1.0"?>
<config>
     <modules>
        <Ddevs_Ebayaff>
            <active>true</active>
            <codePool>local</codePool>
        </Ddevs_Ebayaff>
     </modules>
</config>

I am trying to call controller and mysql install script in one config file as follows

app\code\local\Ddevs\Ebayaff\etc\config.xml

 <?xml version="1.0"?> <config>
        <modules>
            <ddevs_ebayaff>
                <version>
                    0.1.0
                </version>
            </ddevs_ebayaff>
        </modules>   
          <frontend>
            <routers>
                <helloworld>
                    <use>standard</use>
                    <args>
                        <module>Ddevs_Ebayaff</module>
                        <frontName>ebayaffload</frontName>
                    </args>
                </helloworld>
            </routers>
        </frontend>     
     <global>
<resources>
        <add_category_attribute>
            <setup>
                <module>Ddevs_Ebayaff</module>
                <class>Mage_Catalog_Model_Resource_Setup</class>
            </setup>
        </add_category_attribute>
    </resources>

</global>
     </config>

In IndexController, i have the following content

app\code\local\Ddevs\Ebayaff\controllers\IndexController.php

<?php
class Ddevs_Ebayaff_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
           $this->loadLayout();
            $this->renderLayout();
}
}

And my install script as follows:

app\code\local\Ddevs\Ebayaff\sql\add_category_attribute\mysql4-install-0.1.0.php

<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'ddev_ebayaff_cat', array(
    'group'         => 'General Information',
    'input'         => 'text',
    'type'          => 'text',
    'label'         => 'Category ID',
    'backend'       => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => true,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$this->endSetup();
2
In case people come here looking for an answer, there's plenty on the same question on the Magento StackExchange: magento.stackexchange.com/questions/70744/…Mike

2 Answers

1
votes

First make below change in config.xml

<modules>
        <Ddevs_Ebayaff>
            <version>
                0.1.0
            </version>
        </Ddevs_Ebayaff>
    </modules>   

<models>
  <modulename>
    <class>NameSpace_ModuleName_Model</class>
    <resourceModel>modulename_mysql4</resourceModel>
  </modulename>
</models>
<resources>
  <category_setup>
    <setup>
      <module>NameSpace_ModuleName</module>
      <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
    </setup>
    <connection>
      <use>core_setup</use>
    </connection>
  </category_setup>
  <category_write>
    <connection>
      <use>core_write</use>
    </connection>
  </category_write>
  <category_read>
    <connection>
      <use>core_read</use>
    </connection>
  </category_read>
</resources>
0
votes
    <add_category_attribute>

        <setup>
            <module>Ddevs_Ebayaff</module>
            <class>Mage_Catalog_Model_Resource_Setup</class>
        </setup>

      <connection>
           <use>core_setup</use>
      </connection>

    </add_category_attribute>