Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 4 of 4

Thread: Trying to add IsPublished to Entity Product Variants Overview page

  1. #1
    tommy@therave.com is offline Junior Member
    Join Date
    Nov 2011
    Posts
    14

    Default Trying to add IsPublished to Entity Product Variants Overview page

    I'm trying to add the IsPublished field for a variant on the EntityProductVariantsOverview page (between DisplayOrder and IsDefault)

    I've added the fields as other fields displayed on the code page, and I've added an
    <asp:Literal ID="ltIsPublished" runat="server"></asp:Literal>.

    It doesn't error, but it doesn't display. I've tried ltPublished as well.

    Is IsPublished just simply not available via e.Row.FindControl?

    Any thoughts? I'd like to be able to see which variants are published without having to go through each one.

  2. #2
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    In entityProductVariantsOverview.aspx.cs around about line 260ish you need to change:

    Code:
    //SKU
    Literal ltSKU = (Literal)e.Row.FindControl("ltSKU");
    ltSKU.Text = ProductSKU + myrow["SKUSuffix"].ToString();
    			
    //Price
    Literal ltPrice = (Literal)e.Row.FindControl("ltPrice");
    ltPrice.Text = Localization.CurrencyStringForDisplayWithoutExchangeRate(Localization.ParseNativeDecimal(myrow["Price"].ToString()));
    ltPrice.Text += CommonLogic.IIF(Localization.ParseNativeDecimal(myrow["SalePrice"].ToString()) != System.Decimal.Zero, "<br/><span style=\"font-weight: bold; color: red;\">" + Localization.CurrencyStringForDisplayWithoutExchangeRate(Localization.ParseNativeDecimal(myrow["SalePrice"].ToString())) + "</span>", "&nbsp;");
    to add-in the Published literal details:

    Code:
    //SKU
    Literal ltSKU = (Literal)e.Row.FindControl("ltSKU");
    ltSKU.Text = ProductSKU + myrow["SKUSuffix"].ToString();
    			
    // Published
    Literal ltPublished = (Literal)e.Row.FindControl("ltPublished");
    ltPublished.Text = (myrow["Published"].ToString() == "0" ? "No" : "Yes");
    
    //Price
    Literal ltPrice = (Literal)e.Row.FindControl("ltPrice");
    ltPrice.Text = Localization.CurrencyStringForDisplayWithoutExchangeRate(Localization.ParseNativeDecimal(myrow["Price"].ToString()));
    ltPrice.Text += CommonLogic.IIF(Localization.ParseNativeDecimal(myrow["SalePrice"].ToString()) != System.Decimal.Zero, "<br/><span style=\"font-weight: bold; color: red;\">" + Localization.CurrencyStringForDisplayWithoutExchangeRate(Localization.ParseNativeDecimal(myrow["SalePrice"].ToString())) + "</span>", "&nbsp;");
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  3. #3
    tommy@therave.com is offline Junior Member
    Join Date
    Nov 2011
    Posts
    14

    Default Thanks

    Worked like a charm.

    Thanks!

  4. #4
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    Even better would be to replace them with checkboxes which could be used to turn on/off the Published flag, like this:

    Replace:
    Code:
    ltPublished.Text = (myrow["Published"].ToString() == "0" ? "No" : "Yes");
    With this:
    Code:
    ltPublished.Text = "<input type=\"checkbox\" name=\"Published_" + myrow["VariantID"].ToString() + "\"" + CommonLogic.IIF(myrow["Published"].ToString() == "1", " checked ","") + ">";
    And in, entityProductVariantsOverview.aspx.cs protected void btnUpdate_Click(object sender, EventArgs e) around about line 365+

    Replace:
    Code:
    DB.ExecuteSQL("update ProductVariant set IsDefault=0 where ProductID=" + pID.ToString());
    with this:
    Code:
    DB.ExecuteSQL("update ProductVariant set IsDefault=0, Published=0 where ProductID=" + pID.ToString());
    This sets all of the ProductVariants to UnPublished at the beginning of the update function. Then

    Replace this:
    Code:
    for (int i = 0; i <= Request.Form.Count - 1; i++)
    {
    	if (Request.Form.Keys[i].IndexOf("DisplayOrder_") != -1)
    	{
    		String[] keys = Request.Form.Keys[i].Split('_');
    		int VariantID = Localization.ParseUSInt(keys[1]);
    		int DispOrd = 1;
    		try
    		{
    			DispOrd = Localization.ParseUSInt(Request.Form[Request.Form.Keys[i]]);
    		}
    		catch { }
    		DB.ExecuteSQL("update productvariant set DisplayOrder=" + DispOrd.ToString() + " where VariantID=" + VariantID.ToString());
    	}
    }
    with this:
    Code:
    for (int i = 0; i <= Request.Form.Count - 1; i++)
    {
    	if (Request.Form.Keys[i].IndexOf("DisplayOrder_") != -1)
    	{
    		String[] keys = Request.Form.Keys[i].Split('_');
    		int VariantID = Localization.ParseUSInt(keys[1]);
    		int DispOrd = 1;
    		try
    		{
    			DispOrd = Localization.ParseUSInt(Request.Form[Request.Form.Keys[i]]);
    		}
    		catch { }
    		DB.ExecuteSQL("update productvariant set DisplayOrder=" + DispOrd.ToString() + " where VariantID=" + VariantID.ToString());
    	}
    	if (Request.Form.Keys[i].IndexOf("Published_") != -1)
    	{
    		String[] keys = Request.Form.Keys[i].Split('_');
    		int VariantID = Localization.ParseUSInt(keys[1]);
    		int Published = 1;
    		try
    		{
    			Published = Localization.ParseUSInt(Request.Form[Request.Form.Keys[i]]);
    		}
    		catch { }
    		DB.ExecuteSQL("UPDATE [ProductVariant] SET [Published]=1 WHERE [VariantID]=" + VariantID.ToString());
    	}
    }
    The new second part turns on the Published flag where the checkbox has been ticked in the form.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!