Implementing Flash XML with NopCommerce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 13 ans
Thanks to bfranklin825

I want to share with the Nopcommerce community the implementation of a FlashXML components and Nopcommerce in my code.

First take a look to see if one of these components fill your expectations http://www.flashxml.net/components/
Components are free to use and install (watermarked) and $12(no watermark). You can try all the components and their configuration on the same site. Follow the steps for General Installation. In my case I wanted to be able to each time I was uploading pictures for my products to ask me if I want one of those pictures to be included in the control(carousel in my case). If yes then it will update the xml settings with the new uploaded picture.



Modification required.
admin/modules/ProductPictures.ascx -----Add a checkBox

<td class="adminData">
                <nopCommerce:NumericTextBox runat="server" CssClass="adminInput" ID="txtProductPictureDisplayOrder1"
                    Value="1" RequiredErrorMessage="<% $NopResources:Admin.ProductPictures.New.DisplayOrder.RequiredErrorMessage %>"
                    RangeErrorMessage="<% $NopResources:Admin.ProductPictures.New.DisplayOrder.RangeErrorMessage %>"
                    MinimumValue="-99999" MaximumValue="99999" ValidationGroup="UploadNewProductPicture">
                </nopCommerce:NumericTextBox><asp:CheckBox runat="server" ID="chkCarousel"
                    Checked="True" ForeColor="#0033CC" Text="Add to Carousel" />

admin/modles/ProductPictures.ascx.cs


private void addToCarousel()
        {
            var product = this.ProductService.GetProductById(this.ProductId);
            //var variants = product.ProductVariants;
            //var pvID = variants[0].ProductVariantId;

            string num = product.ProductPictures[0].PictureId.ToString();

            if (num.Length < 7)
            {
                for (int i = 0; i < 7 - product.ProductPictures[0].PictureId.ToString().Length; i++)
                {
                    num = string.Format("0{0}", num);
                }
            }
            num = string.Format("{0}.jpeg", num);

            if (chkCarousel.Checked)
            {

                string strFilename = Server.MapPath("~/flash/images.xml");
                XmlDocument xmlPic = new XmlDocument();
                FileStream imgFile = null;

                if (File.Exists(strFilename))
                {
                    string image = "../images/thumbs/" + num;
                    string url = SEOHelper.GetProductUrl(ProductId);
                    string target = "_self";
                    string ccData= product.ShortDescription.Substring(0,15);

                    try
                    {
                        imgFile = new FileStream(strFilename, FileMode.Open, FileAccess.Read);
                        // Open the XML file
                        xmlPic.Load(imgFile);
                    }
                    finally
                    {
                        imgFile.Close();
                    }


                    // Create an element that the new attribute will be added to
                    XmlElement xmlNewPhoto = xmlPic.CreateElement("photo");

                    // Create a Continent element and set its value to
                    // that of the new continent
                    xmlNewPhoto.SetAttribute("image", image);
                    xmlNewPhoto.SetAttribute("url", url);
                    xmlNewPhoto.SetAttribute("target", target);
                    XmlCDataSection cData;
                    cData = xmlPic.CreateCDataSection(ccData);
                    xmlNewPhoto.AppendChild(cData);
                    // Add the element and its attribute to the document
                    xmlPic.DocumentElement.AppendChild(xmlNewPhoto);
                    
                    // Save the XML file
                    xmlPic.Save(Server.MapPath("~/flash/images.xml"));
                }
            }
        }

Here is a work in progress and code implementation results.
Il y a 13 ans
Oh I forgot to include the website http://www.fixmyclick.net
Il y a 13 ans
your web site looks great!

could u send me the smple how it work?? I follw your step to modify file, but no idea how to put it on homepage.

at last, sorry for poor english....
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.