3

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

  • Your comment : Of course the Catalog Price Rule has been applied, but it didn't work. I tried diabling product_flat and category_flat than it work. But enabling product_flat and category_flat it didn't work again – Abdul Jan 15 '16 at 6:17
  • have your setup cron jop on your server? – Abdul Jan 15 '16 at 6:18
  • cron job is running – krybbio Jan 15 '16 at 6:34
2

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%

1

Is Catalog Price Rule has been applied, to do so please open price rule and press Save and Apply button. Its work for me see below screen shot. enter image description here enter image description here


I figure out this problem and regenerated in my magento shop. I tried below steps which is worked for me.

Step 1: Make you Catalog Price Rule status to Inactive and perform Save and Apply action.

Step 2: Disabled Flat Catalog Category & Flat Catalog Product option in System > Configuration > CATALOG > Catalog > Frontend

Step 3: Now change the status of your catalog price rule to Active and clicked on Save and Apply button.

Step 4: Now enabled Flat Catalog Category & Flat Catalog Product and cleared cache and re-indexed Product Flat Data & Category Flat Data

Hope this trick work for you!

  • Of course the Catalog Price Rule has been applied, but it didn't work. I tried diabling product_flat and category_flat than it work. But enabling product_flat and category_flat it didn't work again – krybbio Jan 15 '16 at 5:50
  • I added trick in answer which might be fix your problem. – Jayesh Patel Jan 15 '16 at 7:41
  • 1
    already tryed. Nex time rules ar applied the doesn't work again. – krybbio Jan 15 '16 at 10:31
  • I didn't get "Nex time rules ar applied the doesn't work again." ? – Jayesh Patel Jan 15 '16 at 11:31
  • 1
    Catalog rules are update by cron job – krybbio Jan 15 '16 at 14:09
0

Try these steps:

1/ Disabled the flat mode -> Create catalog price rules -> save & apply the rules -> check on front-end to be sure the rule is applied

2/ Enabled flat mode -> check on front-end and check the tables "catalogrule_product" and "catalogrule_product_price" then feedback if somethings is still wrong

Hope this help

  • This works but next time rules are appied the issue is back. This issue is valid for some condition not all. In this particular case condirtion "contains" doesn't work if flat mode is enable. – krybbio Jan 17 '16 at 11:34
  • @krybbio: have you clicked on "save & apply the rules" ? When you click on it, the final promotion price will be calculated. No matter what to use flat mode or not, the promotion price is stored in its own table. – JoeNguyen Jan 20 '16 at 6:52
  • i clicked "save & apply the rules" but it works only if flat mode is off. – krybbio Jan 20 '16 at 8:43
0

I have improved the code provided by krybbio because it was not working properly for me.

In my case I have made the following replacements:

First line 96 I have replace:

foreach ($value as $v) {
    $results[] = $this->_adapter->quoteInto("{$field}{$selectOperator}", $v);
}

With:

foreach ($value as $v) {
    if (in_array($operator, array("{}", "!{}"))) {
        $v = "%".$v."%";
    }
    $results[] = $this->_adapter->quoteInto("{$field}{$selectOperator}", $v);
}

Then line 114 I have replaced:

} else {
    $result = $this->_adapter->quoteInto("{$field}{$selectOperator}", $value);
}

With:

} else {
    if (in_array($operator, array("{}", "!{}"))) {
        $value = "%".$value."%";
    }
    $result = $this->_adapter->quoteInto("{$field}{$selectOperator}", $value);
}

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.