0

I need to remove an option from original options so I extended the core model. The original file looks like this:

app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php

class Mage_ImportExport_Model_Source_Import_Behavior
{
    /**
     * Prepare and return array of import behavior.
     *
     * @return array
     */
    public function toOptionArray()
    {
        return array(
            array(
                'value' => Mage_ImportExport_Model_Import::BEHAVIOR_APPEND,
                'label' => Mage::helper('importexport')->__('Append Complex Data')
            ),
            array(
                'value' => Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE,
                'label' => Mage::helper('importexport')->__('Replace Existing Complex Data')
            ),
            array(
                'value' => Mage_ImportExport_Model_Import::BEHAVIOR_DELETE,
                'label' => Mage::helper('importexport')->__('Delete Entities')
            )
        );
    }
}

I have an extension that is used to extend all core files and the extended file below. This My_CoreExtension extension is already enabled and extending a few other core files and they are all working fine.

The problem is that my extended Bahavior.php is not called so I know my extend way is not rigtht but I don't know how to fix it.

app/code/local/My/CoreExtension/Model/ImportExport/Source/Import/Behavior.php

class My_CoreExtension_Model_ImportExport_Source_Import_Behavior extends Mage_ImportExport_Model_Source_Import_Behavior
{
    public function toOptionArray()
    {
        return array(
            array(
                'value' => Mage_ImportExport_Model_Import::BEHAVIOR_APPEND,
                'label' => Mage::helper('importexport')->__('Append Complex Data')
            ),
            array(
                'value' => Mage_ImportExport_Model_Import::BEHAVIOR_REPLACE,
                'label' => Mage::helper('importexport')->__('Replace Existing Complex Data')
            ),
        );
    }
}

Here is the config.xml and I've removed unrelated parts.

app/code/local/My/CoreExtension/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <My_CoreExtension>
            <version>1.0.1</version>
        </My_CoreExtension>
    </modules>
    <global>
        <models>
            <importexport>
                <rewrite>
                    <import_source_behavior>My_CoreExtension_Model_ImportExport_Source_Import_Behavior</import_source_behavior>
                </rewrite>
            </importexport>
        </models>
    </global>
</config>

1 Answer 1

0

Found the issue myself. <import_source_behavior> is not only for naming but also tells Magento where to locate the file to replace. According to the original file at app/code/core/Mage/ImportExport/Model/Source/Import/Behavior.php, the naming should be changed to <source_import_behavior>.

Your Answer

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

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