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 Attributesif (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 SkusSubSonic.DeleteQuery deleteProductSkus = new SubSonic.DeleteQuery(Sku.Schema);deleteProductSkus.AddWhere("ProductId", product.ProductId);
deleteProductSkus.Execute();
// LJD 07/11/08 Step 3: Disable the productproduct.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/08btnClearSkus.Attributes.Add("onclick", "return confirm(\"" + LocalizationUtility.GetText("lblConfirmDelete") + "\");return false;");
}
Louis