Exemple #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            // First time the field is loaded in Sitecore shell
            string      xml             = this.Value;
            PriceMatrix priceMatrixItem = PriceMatrix.Load(xml);
            Item        item            = Sitecore.Context.ContentDatabase.SelectSingleItem(PriceMatrixPath);

            this.priceMatrixConfigurationLevel = item.Axes.Level;

            if (!Sitecore.Context.ClientPage.IsEvent)
            {
                var panel = new System.Web.UI.WebControls.Panel();
                panel.Attributes.Add("style", string.Format("padding: 4px, 10px, 10px, 10px; border: 1px solid #CECFCE; background-color: white;"));

                this.Controls.Add(panel);

                if (priceMatrixItem != null)
                {
                    this.IterateRecursiveToLoad(priceMatrixItem.MainCategory, panel, item);
                }
                else
                {
                    this.IterateRecursiveToLoad(null, panel, item);
                }
            }

            base.OnLoad(e);
        }
Exemple #2
0
        /// <summary>
        /// Initalizes the price matrix.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns></returns>
        public static PriceMatrix InitalizePriceMatrix(string xml)
        {
            Item        item        = Sitecore.Context.ContentDatabase.SelectSingleItem(PriceMatrixPath);
            PriceMatrix priceMatrix = PriceMatrix.Load(xml);

            if (priceMatrix == null)
            {
                priceMatrix = new PriceMatrix();
            }

            IterateRecursiveToSave(null, priceMatrix.MainCategory, item, null);
            return(priceMatrix);
        }
Exemple #3
0
        /// <summary>
        /// Gets the price matrix price.
        /// </summary>
        /// <typeparam name="TProduct">The type of the product.</typeparam>
        /// <param name="product">The product.</param>
        /// <param name="priceMatrixName">Name of the price matrix.</param>
        /// <returns>The price.</returns>
        protected override decimal GetPriceMatrixPrice <TProduct>(TProduct product, string priceMatrixName)
        {
            PriceMatrix pm = PriceMatrix.Load(this.priceMatrix);

            string           query           = string.Format("./Shop/{0}", priceMatrixName);
            IPriceMatrixItem priceMatrixItem = pm.SelectSingleItem(query);
            CategoryItem     categoryItem    = priceMatrixItem as CategoryItem;

            if (categoryItem == null)
            {
                return(decimal.Zero);
            }

            string price = categoryItem.Amount;

            decimal priceValue;

            return(!decimal.TryParse(price, out priceValue) ? 0 : priceValue);
        }