in

dashCommerce

An ASP.NET Open Source e-Commerce Application

How To Remove Skus

Last post 08-08-2008 6:15 PM by louisd. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-11-2008 2:08 PM

    How To Remove Skus

    Hi All,

    If the user makes a mistake and enables a product by adding a Sku, there is no way  to start all over.  Until now.

    On the Admin\Controls\Product\Sku.ascx control, add a button next to the save inventory button.

    <asp:Button ID="btnClearSkus" runat="server" CssClass="button" onclick="btnClearSkus_Click" Text="Clear Skus" />

    In the code behind, add the following btnClearSkus_Click method:

    protected void btnClearSkus_Click(object sender, EventArgs e)

    {

    try

    {

    // LJD 07/11/08 Step 1: Delete Attributes

    if (associatedAttributeCollection != null && associatedAttributeCollection.Count > 0)

    {

    SubSonic.
    DeleteQuery deleteAttributeMap = new SubSonic.DeleteQuery("dashCommerce_Store_Product_Attribute_Map");deleteAttributeMap.AddWhere("ProductId", product.ProductId);

    deleteAttributeMap.Execute();

    }

    // LJD 07/11/08 Step 2: Delete Product Skus

    SubSonic.DeleteQuery deleteProductSkus = new SubSonic.DeleteQuery(Sku.Schema);deleteProductSkus.AddWhere("ProductId", product.ProductId);

    deleteProductSkus.Execute();

    // LJD 07/11/08 Step 3: Disable the product

    product.IsEnabled = false;

    product.Save(WebUtility.GetUserName());

    Store.Caching.ProductCache.RemoveProductFromCache(productId);

    SkuCollection savedSkuCollection = LoadSkuCollection(productId);

    if (savedSkuCollection.Count > 0)

    {

    pnlSkuList.Visible =
    false;pnlSkuInventory.Visible = true;

    }

    //base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblAttributesSaved"));

    base.MasterPage.MessageCenter.DisplaySuccessMessage("Skus Deleted");

    }

    catch (Exception ex)

    {

    Logger.Error(typeof(sku).Name + ".btnClearSkus_Click", ex);base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));

    }

    }

    For good meaure, add a Confirm Deletion dialogue in the SetSkuProperties area:

    private void SetSkuProperties () {

    this.Page.Title = LocalizationUtility.GetText("titleProductEditSku");

    LocalizationUtility.AddPanelText(pnlSkuListing);

    LocalizationUtility.AddLabelText(lblSkuDescription);

    LocalizationUtility.AddLabelText(lblTotalSkuCountText);

    LocalizationUtility.AddButtonText(btnSave);

    LocalizationUtility.AddButtonText(btnSaveInventory);

    LocalizationUtility.AddCheckboxText(chkAllowNegativeInventories);

    LocalizationUtility.AddHoverHelp(hlAllowNegativeInventoriesHelp);

    // LJD 07/11/08

    btnClearSkus.Attributes.Add("onclick", "return confirm(\"" + LocalizationUtility.GetText("lblConfirmDelete") + "\");return false;");

    }

    Louis 

     

     

  • 08-08-2008 12:05 AM In reply to

    • jsojka
    • Top 150 Contributor
    • Joined on 02-12-2008
    • Iowa
    • Posts 6

    Re: How To Remove Skus

    This is a great idea. I am trying to install this on my site but I keep getting errors.

     

     Error 1 Type 'MettleSystems.dashCommerce.Web.admin.controls.product.sku' already defines a member called 'SetSkuProperties' with the same parameter types C:\Documents and Settings\Sojka Family\Desktop\dc_3.0.1_Source\Web\admin\controls\product\sku.ascx.cs 338 14 Web

    private void SetSkuProperties () {

     

    Any ideas?

  • 08-08-2008 6:15 PM In reply to

    Re: How To Remove Skus

    Hi JSojka,

    Did you accidentally add a second SetSkuProperties Method?  The note I made was to just add the following within the existing SetSkuPorperties Method:

    // LJD 07/11/08

    btnClearSkus.Attributes.Add("onclick", "return confirm(\"" + LocalizationUtility.GetText("lblConfirmDelete") + "\");return false;");

    Louis

Page 1 of 1 (3 items)