3

I have been trying to override Mage_Adminhtml config.xml, so that Grouped Products do not appear while creating an order from admin.

I have checked line by line, don't know why its not working. The module is appearing in System Config > Advanced

Module Name: VMR_Hidegrouped

app/code/local/VMR/Hidegrouped/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <VMR_Hidegrouped>
            <version>1.0.0</version>
        </VMR_Hidegrouped>
    </modules>
    <adminhtml>
        <sales>
            <order>
                <create>
                    <available_product_types>
                        <simple/>
                        <virtual/>
                        <configurable/>
                    </available_product_types>
                </create>
            </order>
        </sales>
    </adminhtml>
</config>

app/etc/modules/VMR_Hidegrouped.xml

<?xml version="1.0"?>
<config>
    <modules>
        <VMR_Hidegrouped>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Adminhtml/>
            </depends>
        </VMR_Hidegrouped>
    </modules>
</config>
3

I think you cannot do it like this.

The XML files are all merged together, so they are additive rather than overwriting one another.

Thus with your additional file, you are just encouraging the use of simple, virtual and configurable again, but you are not removing anything.

To really remove this, you probably need to be more direct by using an observer and explicitly removing the type (I have not looked if there is a reasonable event for this).

Or if there is no possibility using an observer, a rewrite is in need (this is the last resort, of course ;)).

1

I have accepted mpaepper's answer. We cannot override a node like what I have done. It just gets merged, and NOT overridden. To solve my problem, I had to rewrite the grid block like this.

class Hashid_Hidegrouped_Block_Adminhtml_Sales_Order_Create_Search_Grid extends Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid
{

    public function setCollection($collection){
        $available_product_types = Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray();
        unset($available_product_types['grouped']);
        $collection->addAttributeToFilter('type_id', array_keys($available_product_types));
        parent::setCollection($collection);
    }
}

I am not sure if any event gets fired while fetching config node values, so could not solve it using observer.

1

For other's interested in how to resolve this issue - what @hashid can be done in this situation is instead of using a local override, which will not work as explained in @mpaepper's answer, you will want to create a module and have it depend on VMR_Hidegrouped. This will force your config to be merged after VMR_Hidegrouped is loaded which will cause any duplicate configs to be overridden.

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.