1

I have created a custom attribute for quote item,order item problematically. I have added a drop down option with multiple values for all products.(I don't use custom option because my values are dynamic). I am able to save the selected value of drop down in that custom quote item attribute. But the issue is, if I select the same product with different custom values (the dropdown value I have added), it's updating the quantity of existing quote item.

I want to create new entry of quote item instead of updating existing quote item entry. On which event quote item updated? can anyone help me on which event should I add my logic.

  • have you send custom attribute value in add to cart request? – Abdul Nov 5 '15 at 6:43
1

Magento checks if a product is already in the cart (with the same custom options selected) in the method Mage_Sales_Model_Quote_Item::representProduct.

notice the last 2 if statements

if (!$this->compareOptions($itemOptions, $productOptions)) {
    return false;
}
if (!$this->compareOptions($productOptions, $itemOptions)) {
    return false;
}

these 2 check if there is a difference between the options from the quote item and the options from the product.
You need to rewrite this method and add a new verification, to check if your custom field from the product is different from the custom field you already set on the quote item.
If they are different, return false and Magento will create a new line in the cart with the same product.
Unfortunately I didn't find any events you can use for this, so I think a rewrite is in order.

  • but I have saved this custom option as quote item attribute and it's not part of product attribute – user31071 Nov 5 '15 at 8:18

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.