Magento 1.9 – Catalog Price Rules Condition

catalog-price-rulesmagento-1.9pricerules

I need to make discount oin several product wich skus contain "1513437" like
sku1 = 1513437_01
sku2 = 1513437_02
etc…
So i set a new rule setting condition as

sku contains 1513437

but it doesn't work.

Can anyone help?

EDIT

Magento version 1.9.2.2

with flat mode off it works.

with flat mode on it does not work.

If I use "contain" condition those product are not affected.

If I use "does not contain" condition those product are affected.

If I use "contain" condition whit perfect match it works.

So I think the problem is that the sql query use LIKE instead %LIKE% when flat mode is on

Best Answer

So the problem is in the getOperatorCondition() in app/code/core/Mage/Rule/Model/Resource/Rule/Condition/SqlBuilder.php

            case '!{}':
            if (preg_match('/^.*(category_id)$/', $field) && is_array($value)) {
                $selectOperator = ' IN (?)';
            } else {
                $selectOperator = ' LIKE ?';
            }
            if (substr($operator, 0, 1) == '!') {
                $selectOperator = ' NOT' . $selectOperator;
            }
            break;

on line 67

To solve this problem you can hack the file core changing LIKE with %LIKE% or just simply add % in condition like:

sku contains %1513437%

Related Topic