0

I am trying to use newsletter promotion extension provided at GIT

https://gist.github.com/drewgillson/3009236

Ref for creating promotion condition: http://marius-strajeru.blogspot.ca/2010/04/create-bulk-discount-rules.html

Here I am trying following code for condition

   $conditions['1--2'] = Array
(
'type' => 'salesrule/rule_condition_product_found',
'value' => 0,
'aggregator' => 'all',
'new_child' => '', 
);

$conditions['1--2--1'] = Array
(
'type' => 'salesrule/rule_condition_product',
'attribute' => 'special_price',
'operator' => '<',
'value' => '0',
);

Above code is not working if I try valid attribute code ( second condition ) like 'special_price', 'sku' or 'price'

But if I misspell attribute then it generate promotion rule only attribute is missing from it.

enter image description here

I don't know why attribute is not selected except everything else....

  • Make sure the attributes you are using are available for rule creation. Edit the attribute and set the field Use for Promo Rule Conditions to Yes. A reindex may be required after. – Marius Jul 11 '13 at 7:26
  • yes special price attribute is already in promo rule. I can see it in drop-down in conditions, if check manually. Its quite strange behavior if I try special_price it show error and do not create rule at all, but If I enter incorrect attribute code like specialprice it create rule and as show in screen shot... – Sandesh Jul 11 '13 at 7:33
  • What error do you get? And can you post the full code so I can test it? – Marius Jul 11 '13 at 7:37
  • Its only said there was problem creating coupon. I am trying to figure out it. If I remove this second condition and use only first condition ie subtotal condition it works fine see screen shot. – Sandesh Jul 11 '13 at 7:44
  • 1
    I tried the code from the 'gist' you posted, with your conditions with a minor change. Instead of $rule->setWebsiteIds(1); I used $rule->setWebsiteIds(array(1));. And it worked perfectly. – Marius Jul 11 '13 at 8:27
1

I tried the code from the 'gist' you posted, with your conditions with a minor change. Instead of

$rule->setWebsiteIds(1); 

I used

$rule->setWebsiteIds(array(1));

And it worked perfectly.

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.