php - Item disappearing from cart when logging in when Mage_Sales_Order_Quote is overridden not to


Magento version is I have overriddenMage_Sales_Order_Quote inapp/code/local to not just increase quantity if thedesiger option is set. I have a design system that a person can click a link in the product view and they are taken to the designer that we made, then the product is added pragmatically to cart.

I changed thegetItemByProduct to the following:

public function getItemByProduct($product)
    $_options = unserialize($product->getCustomOption('info_buyRequest')->getValue());
    $_designs = $_options['options']['designer'];
    foreach ($this->getAllItems() as $item) {
        if ($item->representProduct($product)) {
            $_itemOptions = unserialize($item->getProduct()->getCustomOption('info_buyRequest')->getValue());
            if (!empty($_designs) && !empty($_itemOptions['options']['designer'])) { // consider detecting if this was a re-design
                return false;
            } else {
                return $item;
    return false;

Now, the functionality works as intended, except for the fact that if I am logged out and have items in the cart, when I log in the items are merged once again like default functionality used to be and not my override. Where else would I look to remove this? I have the "Save Cart to Database" setting enabled to make carts persistent, in case that is relevant.




Create an Observer that listens to the eventsales_quote_merge_before and clears the customer's saved cart:

Create an Observer class at/app/code/local/{namespace}/{yourmodule}/Model/Observer.php

class <namespace>_<modulename>_Model_Observer
  public function preventMerge(Varien_Event_Observer $observer)
    // Clear the customer's cart

Then, add the following to your /app/code/local/{namespace}/{yourmodule}/etc/config.xml file for the module:


People are also looking for solutions to the problem: mysql - Filtering using php if statement


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.