0

Can anyone throw some light on how to remove 'Attribute Set' from conditions for "Catalog Price Rule" in the the admin section in a better way.

I can do the following thing. In the class Mage_Rule_Model_Condition_Product_Abstract I comment for attribute_set_id 'Attribute Set'

protected function _addSpecialAttributes(array &$attributes)
    {
        $attributes['attribute_set_id'] = Mage::helper('catalogrule')->__('Attribute Set');
        $attributes['category_ids'] = Mage::helper('catalogrule')->__('Category');
    }

But this is the abstract class so I can't extend this one.

So I need a better way to do this.

1 Answer 1

2

This gets into the curious decision of whether to implement the change one time in a superseding class definition, or implementing the change multiple times in concrete-/sub-classes. There are a few things to consider when deciding how to change core logic:

  1. Local change or public module
  2. Availability & suitability of events
  3. Magento flavor (CE/EE), because of the number of classes extending the main

#1 is something for you answer for yourself - if it is a local change then you have less restrictions on how you implement.

#2 is generally the more extendable, cross-cutting way to get your changes done. In this case, there are none :-(

#3 is where your needs lie. Because there are no events, you are forced to consider the number of rewrites versus a proper core redefinition. For CE install there are 2 subclasses of this abstract class, so I might be inclined to just do a rewrite on those. For an EE install there are 8 subclasses, which I would be loathe to rewrite with such a gross violation of DRY.

Ultimately how you implement a definition change is subject to the criterion of maintainability, and it seems that it is more maintainable to implement this by copying the Mage_Rule_Model_Condition_Product_Abstract to the local codepool, implementing your change, and stating this in the release notes.

2
  • Nice explanation.However one question. Suppose there is an event attached to a function then, it is better to write an observer than to override it? Commented Aug 20, 2013 at 9:46
  • If you are developing a third-arty module, it's imperative. We do mostly local implementations but tend to use observers.
    – benmarks
    Commented Aug 20, 2013 at 12:10

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.