My magento has two warehouses, and the cart cannot have two products with different warehouses. I check this with an observer. But, I have a problem:

A logged user has in his cart a product with the warehouse A. And he logs out. After, a guest user add to his cart a product with the warehouse B. And finally, the first user is logged again and in his cart appears a product with A and other with B.

How can I resolve it? The product B should not appear in the cart in the last step.

Please help.

  • that means,you want to remove item product B from system – Amit Bera Dec 24 '15 at 8:15

Magento use the Sales_Model_Quote::merge() Method to merge the current cart with the customer cart after login. I suggest you to hook the sales_quote_merge_after event to run the warehouse validation

Check if some module is "hooking" the same event and then evaluate to add it as dependency or your module to perform your validation after any other.

BTW I have a very similar issue in my next week backlog :)

| improve this answer | |
  • One more thing... i recommend you to implement the warehouse validation on a helper instead a model in order to reuse it in some other place (like a after a warehouse switch o wherever. – MauroNigrele Dec 24 '15 at 8:54

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.