in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Just a suggestion.

Last post 07-05-2008 6:08 PM by admin. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-05-2008 12:38 AM

    Just a suggestion.

    Wouldn't it be better to delete a product using a stored procedure?

    That way, you can first start deleting FK relationships down the relationship hiarchey on up.

    Right now, products can't be deleted when becoming active.

    There are other situations like this in the core.

    ~Paul
  • 07-05-2008 9:53 AM In reply to

    Re: Just a suggestion.

    You can "delete" products when they are active (or inactive), but it is a logical delete, not a hard delete. The reason for this is products may have inventory / sales numbers attached to them, so you may want to preserve those numbers for reporting. It's a store specific thing to do hard deletes - meaning all the data is removed. We decided to error on the side of preserving data. Doing a hard delete is a feature we can add, so if you want it, please add it at CodePlex and we'll see if we can add it in a future release.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-05-2008 2:21 PM In reply to

    Re: Just a suggestion.

       protected void btnDelete_Click(object sender, EventArgs e) {
          try {
            Product.Delete(productId);
            base.MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblProductSaved"));
          }
          catch(Exception ex) {
            Logger.Error(typeof(general).Name + ".btnDelete_Click", ex);
            base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText       (ex.Message));
          }
        }

    Here you are trying to delete the whole product rather than setting the IsDeleted to true. This would never work with all the enforced relationships. Maybe we could just simply create relationships that don't get enforced?

    ~Paul
  • 07-05-2008 2:48 PM In reply to

    Re: Just a suggestion.

    It's a soft / logical delete. It sets the Product.IsDeleted property to true.

    theonlylawislove:
    Maybe we could just simply create relationships that don't get enforced?

    Not a fan of that - it puts too much pressure on the developer to understand the intent of the original developer. It might work for me (because I know dC so well), but for someone new, it would be a slippery slope - unless you're a mind reader Wink.

    As I mentioned, we could do a hard delete, in which case you're correct about the relationships - we would have to remove all the dependencies first, then do a hard delete of the product itself. But right now, we don't do hard deletes because of what I mentioned about inventory / reporting.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-05-2008 3:25 PM In reply to

    Re: Just a suggestion.

    The delete method is inherit from ActiveRecord. Are you saying subsonic sets the IsDeleted to 1/true?

    ~Paul
  • 07-05-2008 3:42 PM In reply to

    Re: Just a suggestion.

    Yep, sorry, I probably should have explained that sooner. Embarrassed

    Think about reports. If you delete a product and you run a sales report, you are going to lose any of that sales data - which means your report would be incorrect.

    If I sell 10 widgets for $10 and then blow away everything related to that product since I don't sell widgets anymore, then my sales report will be off by $100. That is why we do logical deletes.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-05-2008 3:44 PM In reply to

    Re: Just a suggestion.

    Well, I guess it does do that.

    How? Where is the code that does it?

    ~Paul
  • 07-05-2008 6:08 PM In reply to

    Re: Just a suggestion.

    Burried in the ActiveRecord stuff I would imagine. Probably have to look at the SubSonic code to find that one.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
Page 1 of 1 (8 items)