I have created a custom column named 'campaign_id' through UpgradeSchema in quote table as below.

         'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
         'length' => 11,
         'nullable' => false,
         'comment' => 'Campaign ID'

I am setting its value through custom controller on add to cart as below

// \Magento\Checkout\Model\Session


The value is getting saved properly when I'm adding product as a guest user or as a logged in user.

However when I add the product as a guest user and then log in, the custom quote column value from guest quote is not getting copied to customer quote on quote merge.

1 Answer 1


I did it using the sales_quote_merge_after event


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <event name="sales_quote_merge_after">
        <observer name="sales_quote_merge_custom_column" instance="Namespace\Module\Observer\SalesQuoteMergeAfter" />


namespace Namespace\Module\Observer;

use Magento\Framework\Event\ObserverInterface;

class SalesQuoteMergeAfter implements ObserverInterface
    public function execute(\Magento\Framework\Event\Observer $observer)
        $guestQuote = $observer->getEvent()->getSource();   //before merge
        $customerQuote = $observer->getEvent()->getQuote(); //after merge

        if($guestQuote->getCampaignBlockId()) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.