1

I have products where multiple grouped products have the same simple product.

Simple Product SKU: prod1_1

Grouped Product1 SKU: group1_1 - associated product: prod1_1 Grouped Product2 SKU: group2_2 - associated product: prod1_1

I want to set up a coupon rule that will only apply to group1_1/prod1_1, but not group2_2/prod1_1. From what I've seen, the coupon code only seems to apply to the simple product. Is there a setting I'm missing, or would that be something custom?

1

This is not possible 'out of the box', because when adding a part of the grouped product to the cart there is no direct reference to the grouped product for the quote item table. The reference is serialized in the item options (see below).
Honestly, from my point of view, it doesn't even make sense because the following 3 scenarios have the same result.
Scenario 1
The customer views the page for group1_1 and adds to cart product prod1_1.
Scenario 2
The customer views the page for group2_2 and adds to cart product prod1_1.
Scenario 3
The customer views the page for prod1_1 (if visible) and adds the product to cart.
In all of these 3 cases the customer will buy the same product and the moral thing is to give him/her the discount.
but if you still insist on doing it, here is how I would do it. It's not simple, I'm not sure it will work but it seams like the way to go.
When adding part of a group product to the cart remember in an additional field in sales_flat_quote_item (you should add the field) then try to create a new rule criteria to take into consideration your new field.
The hints I can give you are :

  1. You can try to use this event sales_quote_product_add_after. For each item passed to that event in the item options you should find the only reference to the grouped product. In field info_buyRequest. (see how $item->getOptions() looks like).
  2. To be able to add a new field for rule conditions under Product attribute combination->Cart Item attribute similar to Price in cart or Quantity in cart you need to override Mage_SalesRule_Model_Rule_Condition_Product::_addSpecialAttributes()
| improve this answer | |
  • Thanks, I was afraid of that. My plan was actually to overwrite the rules modules slightly and have it check $item->getParent()/getParentId() as well as the sku. – aynber Jun 27 '13 at 12:42
  • But since the parentID gets changed each time a different grouped with the same simple gets added to the cart, it's a moot point. Though the way we have the store set up, most people won't buy the same simple from different grouped at the same time. – aynber Jun 27 '13 at 13:24
  • You cant use parent_id with grouped products. There is no parent_id added to the quote item when you add a grouped product to the cart. That's what I was saying in my answer. – Marius Jun 27 '13 at 13:27
  • Sure there is. Well, not exactly parentID, but there is $item->getParentItem(). I use it in other scripts when manually creating orders, to add the quote item to the order. – aynber Jun 27 '13 at 13:57

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.