0

How to change Magento's default tables using install script of custom modules?

I need to change "eav_attribute" table's "Telephone" column using install script. My intention is to set "is_required" field to set to 1 in that table..., to get past validation.

I am a little bit new to magento, any help will be appreciated.

1 Answer 1

2

1) Declare a setup resource and a module version to trigger the setup workflow for a module:

<config>
    <Your_Module>
        <version>0.1.0</version> <!-- whatever -->
    </Your_Module>
    <global>
        <resources>
            <your_module_setup>
                <setup>
                    <module>Your_Module</module>
                </setup>
            </your_module_setup>
        </resources>
    </global>
</config>

2) Create an install script Your/Module/sql/your_module_setup/install-0.1.0.php which (as a matter of style) uses the customer/setup class:

$installer = Mage::getResourceModel('customer/setup','customer_setup');
/* @var $installer Mage_Customer_Model_Resource_Setup */
$installer->startSetup();

//Proposed edit is correct: entity is customer_address not customer
//$installer->updateAttribute('customer','telephone','is_required',false);
$installer->updateAttribute('customer_address','telephone','is_required',false);

$installer->endSetup();

Clear the config cache, hit any page, and this should update the attribute param.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.