Page 1 of 1

Foreign key insert conflicted error 7.0.3

Posted: Tue Aug 04, 2009 11:32 am
by AbleMods
Sigh I can't find anything today. I swear I saw a fix somewhere for this error, maybe I'm wrong. I've got customers getting this during checkout. Anyone else getting this in 7.0.3 - it's a standard unmodified install.
The INSERT statement conflicted with the FOREIGN KEY constraint "ac_Baskets_ac_BasketItems_FK1". The conflict occurred in database "AbleMods", table "dbo.ac_Baskets", column 'BasketId'

Re: Foreign key insert conflicted error 7.0.3

Posted: Tue Aug 04, 2009 12:43 pm
by jmestep
Yes, that's a known bug. I was able to patch a couple of sites.
viewtopic.php?f=42&t=11348&hilit=FOREIGN+KEY

Re: Foreign key insert conflicted error 7.0.3

Posted: Tue Aug 04, 2009 1:56 pm
by AbleMods
Well apparently you missed mine :P

Thanks a bunch Judy, your memory serves you far better than mine these days. I've made the change, we'll see if that fixes it for me.

Re: Foreign key insert conflicted error 7.0.3

Posted: Tue Sep 13, 2011 11:10 pm
by Ming-Chu
Hi all,

My AC version is VERSION: 7.0.7.14481 but my customers have still got this error during checkout.

I check ConLib/OnePageCheckout.ascx.cs, I find the code basket.Package(false, true) as below:

Code: Select all

    private void InitializeBasket()
    {
        Basket basket = Token.Instance.User.Basket;
        basket.Package(false, true);
        foreach (BasketShipment shipment in basket.Shipments)
        {
            shipment.ShipMethodId = 0;
            shipment.Save();
        }
        basket.Recalculate();
        _CurrentBasketHash = basket.GetContentHash(OrderItemType.Product);
    }
And I check ConLib/Basket.ascx.cs, I also find basket.Package(false, false) in Page_PreRender() and GetBasketItems().

Code: Select all

    private BasketItemCollection GetBasketItems()
    {
        User user = Token.Instance.User;
        Basket basket = user.Basket;
        basket.Package(false, false);
        _DisplayedBasketItems = new BasketItemCollection();
       // ignore...
    }

Code: Select all

    protected void Page_PreRender(object sender, EventArgs e)
    {
        //GET ANY MESSAGES FROM SESSION
        List<string> sessionMessages = Session["BasketMessage"] as List<string>;
        //GET THE BASKET AND RECALCULATE
        Basket basket = Token.Instance.User.Basket;
        basket.Package(false, false);
        basket.Recalculate();
        // ignore...
    }
I have compared ConLib/Basket.ascx.cs in Service Release for AC 7.0.3 and my AC 7.0.7.
The different is that AC7.0.3 uses basket.Package() but AC7.0.7 uses basket.Package(false, false).

My error log is as below.
errorlog.JPG
I am not sure what is the solution and how to fix it?

Could anybody help me?

Thank you!!