0

Magento Version 1.9.3.7

The scenario is:

I need to set up a Catalog Price Rule for specific brand's products. So i set up condition "Manufacturer is BrandName".

Now I need to exclude some product from thet rule.

If i set up "SKU is not one of" with just one sku it works fine, but if is an array of skus the rule will be applied to all catalog.

The follow is applied to all catalog:

If ALL  of these conditions are TRUE :

    Manufacturer  is  BrandName
    SKU  is not one of  sku1, sku2

the follow works as expected:

If ALL  of these conditions are TRUE :

    Manufacturer  is  BrandName
    SKU  is not one of  sku1

the follow works as expected:

If ALL  of these conditions are TRUE :

    Manufacturer  is  BrandName
    SKU  is one of  sku1, sku2

Guess the array will break the condition set so that it will result "empty condition" than good for all products.

1 Answer 1

2

the issue is in Mage_Rule_Model_Resource_Rule_Condition_SqlBuilder class in

public function getOperatorCondition()

need to change on line 109

$result = implode(in_array($operator, array('()', '!()')) ? ' OR ' : ' AND ', $results);

with

$result = implode(in_array($operator, array('()', '[]')) ? ' OR ' : ' AND ', $results);

than everythig works as expected

3
  • [] is just another array syntax and no replacement for !(). I'm pretty sure this will break other rules. Not exactly the same, but may helperfl for others ... magento.stackexchange.com/questions/36195/…
    – sv3n
    Commented Feb 15, 2018 at 19:12
  • 1
    @sv3n '[]' => Mage::helper('rule')->__('contains') as you can see in Mage_Rule_Model_Condition_Abstract. What I've done is to have the "OR" condition when operatator is "FIND_IN_SET" and the "AND" condition when is "NOT FIND_IN_SET"
    – krybbio
    Commented Feb 15, 2018 at 19:37
  • @sv3n as is said in magento.stackexchange.com/a/71332/15051 that issue is been solved in CE 1.9.3 what i've posted is different
    – krybbio
    Commented Feb 15, 2018 at 19:43

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.