1

I wrote module which will create a new varchar field in sales_flat_order. For this we create seutp set but it not working ,where the issue: app/code/local/Bh/Affiliate/etc/config.xml

<?xml version="1.0" ?>
<config>
    <modules>
        <Bh_Affiliate>
            <version>1.0.0</version>
        </Bh_Affiliate>
    </modules>
    <global>    
        <models>    
        <affiliate> 
            <class>Bh_Affiliate_Model</class>
            <resourceModel>affiliate_resource</resourceModel>
            </affiliate>
             <affiliate_resource>
                <class>Bh_Affiliate_Model_Resource</class>
                </affiliate_resource>
        </models>
            <resources>
             <affiliate_setup>
                  <setup>
                   <module>Bh_Affiliate</module>
                   <class>Mage_Sales_Model_Entity_Setup </class>
                 </setup>
            </affiliate_setup>
            </resources>
    <fieldsets>
          <sales_convert_quote>                          
                <affiliate_details><to_order>*</to_order></affiliate_details>
            </sales_convert_quote>

            <sales_convert_order>                                             
                <affiliate_details><to_quote>*</to_quote></affiliate_details>
            </sales_convert_order>
        </fieldsets>

    </global>
    <frontend>
        <routers>
            <affiliate>
                <use>standard</use>
                <args>
                    <module>Bh_Affiliate</module>
                    <frontName>affiliate</frontName>
                </args>
            </affiliate>
        </routers>
    </frontend>
</config>

app/code/local/Bh/Affiliate/sql/affiliate_setup/install-1.0.0.php

<?php

$installer = $this;
$installer->startSetup();
$options = array(
    'type'     => Varien_Db_Ddl_Table::TYPE_VARCHAR,
    'visible'  => false,
    'required' => false
);
$installer->addAttribute('order', 'affiliate_details', $options);

$installer->endSetup();
/*
$installer = $this;
$installer->startSetup();
$installer->addAttribute(
    'order', 
    'affiliate_details', 
    array(
        'type' => 'varchar', 
        'grid' => false 
    )
);
$installer->endSetup();
*/
/*
$installer = $this;

$installer->getConnection()
    ->addColumn($installer->getTable('sales/order'), 'affiliate_details', array(
        'TYPE'      => Varien_Db_Ddl_Table::TYPE_VARCHAR,
        'LENGTH'    => 255,
        'NULLABLE'  => true,
        'COMMENT'   => 'Affiliate Details'
    ));


*/

app/etc/modules/Bh_Affiliate.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Bh_Affiliate>
            <codePool>local</codePool>
            <active>true</active>
        </Bh_Affiliate>
    </modules>
</config>
10
  • /sql/Affiliate_setup/install-1.0.0.php should be /sql/affiliate_setup/install-1.0.0.php...lowercase a.
    – Marius
    Jul 15 '14 at 10:44
  • @marius it was my typo mistakes.Now check where the issue ..
    – Amit Bera
    Jul 15 '14 at 11:01
  • Check the table core_resource for a record with code affiliate_setup. If there is one, remove it.
    – Marius
    Jul 15 '14 at 11:05
  • have the records...affiliate_setup in table
    – Amit Bera
    Jul 15 '14 at 11:06
  • 1
    tried it. It works fine. Make sure you cleared the cache after removing the record from core_resource
    – Marius
    Jul 15 '14 at 11:37
2

I got the solution ,Just change the setup class

Mage_Sales_Model_Entity_Setup

To

Mage_Sales_Model_Resource_Setup

And it work now.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.