コード例 #1
0
        /// <summary>
        /// Get product variant attribute values
        /// </summary>
        /// <param name="Attributes">Attributes</param>
        /// <returns>Product variant attribute values</returns>
        public static ProductVariantAttributeValueCollection ParseProductVariantAttributeValues(string Attributes)
        {
            ProductVariantAttributeValueCollection pvaValues     = new ProductVariantAttributeValueCollection();
            ProductVariantAttributeCollection      pvaCollection = ParseProductVariantAttributes(Attributes);

            foreach (ProductVariantAttribute pva in pvaCollection)
            {
                if (!pva.ShouldHaveValues)
                {
                    continue;
                }

                List <string> pvaValuesStr = ParseValues(Attributes, pva.ProductVariantAttributeID);
                foreach (string pvaValueStr in pvaValuesStr)
                {
                    if (!String.IsNullOrEmpty(pvaValueStr))
                    {
                        int pvaValueID = 0;
                        if (int.TryParse(pvaValueStr, out pvaValueID))
                        {
                            ProductVariantAttributeValue pvaValue = ProductAttributeManager.GetProductVariantAttributeValueByID(pvaValueID);
                            if (pvaValue != null)
                            {
                                pvaValues.Add(pvaValue);
                            }
                        }
                    }
                }
            }
            return(pvaValues);
        }
コード例 #2
0
        private static ProductVariantAttributeValueCollection DBMapping(DBProductVariantAttributeValueCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            ProductVariantAttributeValueCollection collection = new ProductVariantAttributeValueCollection();

            foreach (DBProductVariantAttributeValue dbItem in dbCollection)
            {
                ProductVariantAttributeValue item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }