Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:02:16+00:00 2026-06-13T10:02:16+00:00

I have the observer sales_quote_add_item in config.xml which run function below when item is

  • 0

I have the observer sales_quote_add_item in config.xml which run function below when item is added to cart:

    public function updatePrice( $observer ){

        $event = $observer->getEvent();

        $quote_item = $event->getQuoteItem();

        $new_price = 200;
        $quote_item->setOriginalCustomPrice($new_price);
        $quote_item->setTotalPrice(350);

        $quote_item->save();
}

It’s working fine if user is registered but if we are as guest then this line

$quote_item->save();

give error in var/exception.log

2012-10-23T05:12:28+00:00 DEBUG (7): Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`bluning_mage`.`sales_flat_quote_item`, CONSTRAINT `FK_SALES_QUOTE_ITEM_SALES_QUOTE` FOREIGN KEY (`quote_id`) REFERENCES `sales_flat_quote` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE)

How can I solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:02:18+00:00Added an answer on June 13, 2026 at 10:02 am

    You should not save quote item object in observer, so just remove this line:

    $quote_item->save();

    It will save the object automatically, as it is being passed by reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added an observer on sales_order_place_before Event and want to customize grand total
I have a UIView subclass with an added observer for the UIKeyboardWillShowNotification and UIKeyboardWillHideNotification
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
I have an observer which looks like this: class CommentObserver < ActiveRecord::Observer include ActionView::Helpers::UrlHelper
I have make custom module in which I have make observer file. the observer
I have used Observer Pattern for my application. I have a subject which has
I have observer for Magento event checkout_cart_product_add_after. Now I need to check if for
I have an observer that removes items from the cart if they are out
I have made a generic Observer interface and an Observable class, but can't compile
I have a problem with Observer-Pattern and deadlock using threads. package observerDeadLock; import java.util.Observable;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.