Exemplo n.º 1
0
 public OpenBoxViewModel(OpenBoxDto item,
                         StyleEntireDto style,
                         IList <StyleItemDTO> styleItems,
                         List <OpenBoxItemDto> boxItems)
 {
     ConstructFrom(item, style, styleItems, boxItems);
 }
 public SealedBoxViewModel(SealedBoxDto item,
                           StyleEntireDto style,
                           List <StyleItemDTO> styleItems,
                           List <SealedBoxItemDto> boxItems)
 {
     ConstructFrom(item, style, styleItems, boxItems);
 }
Exemplo n.º 3
0
 public ParentItemDTO CreateAndMergeWithExistFromStyle(IUnitOfWork db,
                                                       StyleEntireDto style,
                                                       MarketType market,
                                                       string marketplaceId,
                                                       out IList <MessageString> messages)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public OpenBoxViewModel(IUnitOfWork db,
                         OpenBoxDto item,
                         StyleEntireDto style,
                         IList <StyleItemDTO> styleItems,
                         List <OpenBoxItemDto> boxItems,
                         List <OpenBoxTrackingDTO> boxTrackings)
 {
     ConstructFrom(db, item, style, styleItems, boxItems, boxTrackings);
 }
        public static ItemExportViewModel FromParentASIN(IUnitOfWork db,
                                                         string asin,
                                                         int market,
                                                         string marketplaceId,
                                                         out IList <MessageString> messages)
        {
            messages = new List <MessageString>();

            var parentItem = db.ParentItems.GetAllAsDto().FirstOrDefault(s => s.ASIN == asin &&
                                                                         s.Market == market &&
                                                                         s.MarketplaceId == marketplaceId);

            if (parentItem == null)
            {
                messages.Add(MessageString.Error("Parent ASIN was not found"));
                return(null);
            }

            var items = db.Items.GetAllViewAsDto().Where(i => i.ParentASIN == parentItem.ASIN &&
                                                         !i.IsFBA &&
                                                         i.Market == parentItem.Market &&
                                                         i.MarketplaceId == parentItem.MarketplaceId)
                        .ToList();

            foreach (var item in items)
            {
                item.BrandName = item.BrandName ?? parentItem.BrandName;
            }

            var model = new ItemExportViewModel();

            var            mainItem = items.FirstOrDefault();
            StyleEntireDto style    = mainItem != null && mainItem.StyleId.HasValue
                ? db.Styles.GetByStyleIdAsDto(mainItem.StyleId.Value)
                : null;

            var firstStyleString = items.Any() ? items.First().StyleString : "";

            model.ASIN = parentItem.ASIN;
            model.Id   = parentItem.Id;

            model.Market        = (int)market;
            model.MarketplaceId = marketplaceId;

            model.Name = parentItem.AmazonName;

            model.PictureSourceType = PictureSourceTypes.FromStyle; //NOTE: always generate excel with fresh images
            model.ListingImage      = mainItem?.ImageUrl;
            model.StyleImage        = style?.Image;

            model.VariationList = items
                                  .OrderBy(i => i.StyleId)
                                  .ThenBy(i => SizeHelper.GetSizeIndex(i.StyleSize))
                                  .Select(i => new ItemVariationExportViewModel(i)).ToList();

            return(model);
        }
        public static StyleChangeViewModel BuildCreateChange(StyleEntireDto style)
        {
            return(new StyleChangeViewModel()
            {
                ChangeName = "Created",

                ChangeDate = style.CreateDate,
                ChangedBy = style.CreatedBy
            });
        }
        private void ConstructFrom(SealedBoxDto item,
                                   StyleEntireDto style,
                                   List <StyleItemDTO> styleItems,
                                   List <SealedBoxItemDto> boxItems)
        {
            Id      = item.Id;
            StyleId = item.StyleId;
            if (style != null)
            {
                StyleString = style.StyleID;
            }

            BoxBarcode       = item.BoxBarcode;
            Printed          = item.Printed;
            PolyBags         = item.PolyBags;
            BoxQuantity      = item.BoxQuantity;
            Owned            = item.Owned;
            Price            = item.PajamaPrice;
            Archived         = item.Archived;
            UpdateDate       = item.UpdateDate;
            CreateDate       = item.CreateDate;
            OriginCreateDate = item.OriginCreateDate;

            UpdatedByName = item.UpdatedByName;

            BoxItemsQuantity = boxItems.Sum(b => b.BreakDown);

            StyleItems = new StyleItemCollection()
            {
                DisplayMode = StyleItemDisplayMode.BoxBreakdown,
                Items       = styleItems
                              .OrderBy(si => SizeHelper.GetSizeIndex(si.Size))
                              .ThenBy(si => si.Color)
                              .Select(si => new StyleItemViewModel(si)).ToList()
            };

            //Set boxes values
            foreach (var boxItem in boxItems)
            {
                var styleItem = StyleItems.Items.FirstOrDefault(si => si.Id == boxItem.StyleItemId);
                if (styleItem != null)
                {
                    styleItem.Breakdown = boxItem.BreakDown;
                    styleItem.BoxItemId = boxItem.Id;
                }
            }

            Breakdown = string.Join("-", StyleItems.Items
                                    .OrderBy(si => SizeHelper.GetSizeIndex(si.Size))
                                    .ThenBy(si => si.Color)
                                    .Where(si => si.Breakdown.HasValue)
                                    .Select(si => si.Breakdown).ToList());
        }
Exemplo n.º 8
0
        private void ConstructFrom(IUnitOfWork db,
                                   OpenBoxDto item,
                                   StyleEntireDto style,
                                   IList <StyleItemDTO> styleItems,
                                   List <OpenBoxItemDto> boxItems,
                                   List <OpenBoxTrackingDTO> boxTrackings)
        {
            Id      = item.Id;
            StyleId = item.StyleId;

            if (style != null)
            {
                StyleString = style.StyleID;
            }

            Type = item.Type;

            BoxBarcode  = item.BoxBarcode;
            Printed     = item.Printed;
            PolyBags    = item.PolyBags;
            BoxQuantity = item.BoxQuantity;
            Price       = item.Price;
            Owned       = item.Owned;
            Archived    = item.Archived;

            CreateDate = item.CreateDate;
            UpdateDate = item.UpdateDate;

            UpdatedByName = item.UpdatedByName;

            SizesQuantity = boxItems.Sum(s => s.Quantity);

            StyleItems = new StyleItemCollection()
            {
                DisplayMode = StyleItemDisplayMode.BoxQty,
                Items       = styleItems
                              .OrderBy(si => SizeHelper.GetSizeIndex(si.Size))
                              .ThenBy(si => si.Color)
                              .Select(si => new StyleItemViewModel(si))
                              .ToList()
            };

            //Set boxes values
            foreach (var boxItem in boxItems)
            {
                var styleItem = StyleItems.Items.FirstOrDefault(si => si.Id == boxItem.StyleItemId);
                if (styleItem != null)
                {
                    styleItem.Quantity  = boxItem.Quantity;
                    styleItem.BoxItemId = boxItem.Id;
                }
            }
        }
        public static StyleHistoryViewModel GetByStyleString(IUnitOfWork db,
                                                             ILogService log,
                                                             string styleString)
        {
            StyleEntireDto style = null;

            if (!String.IsNullOrEmpty(styleString))
            {
                styleString = StringHelper.TrimWhitespace(styleString);
                style       = db.Styles.GetActiveByStyleIdAsDto(styleString);
            }

            if (style == null)
            {
                return(null);
            }
            else
            {
                var qtyChanges = db.StyleItemQuantityHistories.GetAllAsDto().Where(si => si.StyleId == style.Id)
                                 .OrderByDescending(sq => sq.CreateDate)
                                 .Take(15)
                                 .ToList()
                                 .Select(ch => new StyleChangeViewModel(ch))
                                 .ToList();

                var changes = db.StyleChangeHistories.GetByStyleIdDto(style.Id)
                              .ToList()
                              .OrderByDescending(ch => ch.ChangeDate)
                              .Select(ch => new StyleChangeViewModel(ch))
                              .Where(ch => !String.IsNullOrEmpty(ch.ChangeName)) //NOTE: Skipped empty
                              .ToList();

                changes.Add(StyleChangeViewModel.BuildCreateChange(style));
                changes.AddRange(qtyChanges);

                return(new StyleHistoryViewModel
                {
                    //Notes =  string.Format("{0} {1}", order.OrderId, itemsNotes),
                    StyleString = style.StyleID,
                    StyleId = style.Id,

                    Changes = changes.OrderByDescending(c => c.ChangeDate).ToList(),
                });
            }
        }
        public static IList <ExcelWFSProductUSViewModel> GetItemsFor(IUnitOfWork db,
                                                                     IMarketCategoryService categoryService,
                                                                     ExportToExcelMode exportMode,
                                                                     IList <FBAItemInfo> fbaItems,
                                                                     ParentItemDTO parent,
                                                                     IList <ItemExDTO> children,
                                                                     UseStyleImageModes useStyleImageMode,
                                                                     out string filename)
        {
            var models = new List <ExcelWFSProductUSViewModel>();

            filename = null;

            var defaultChild = children.OrderByDescending(ch => ch.IsExistOnAmazon).ThenBy(ch => ch.Id).FirstOrDefault();

            if (!children.Any() && exportMode != ExportToExcelMode.Normal)
            {
                return(models);
            }

            FeatureValueDTO defaultChildSubLicense = null;
            var             defaultChildItemStyle  = String.Empty;
            var             defaultChildGender     = String.Empty;
            var             defaultChildBrand      = String.Empty;
            StyleEntireDto  firstChildStyle        = null;
            string          mainBrandName          = null;
            decimal?        childListPrice         = null;
            string          childDepartment        = null;
            string          childSize            = null;
            string          childStyleString     = null;
            IList <string>  defaultChildFeatures = new List <string>();

            if (defaultChild != null && defaultChild.StyleId.HasValue)
            {
                defaultChildSubLicense = db.FeatureValues.GetValueByStyleAndFeatureId(defaultChild.StyleId.Value, StyleFeatureHelper.SUB_LICENSE1);
                defaultChildItemStyle  = ItemExportHelper.GetFeatureValue(db.FeatureValues.GetValueByStyleAndFeatureId(defaultChild.StyleId.Value, StyleFeatureHelper.ITEMSTYLE));
                defaultChildGender     = ItemExportHelper.GetFeatureValue(db.FeatureValues.GetValueByStyleAndFeatureId(defaultChild.StyleId.Value, StyleFeatureHelper.GENDER));
                defaultChildBrand      = ItemExportHelper.GetFeatureValue(db.FeatureValues.GetValueByStyleAndFeatureId(defaultChild.StyleId.Value, StyleFeatureHelper.BRAND));

                mainBrandName = StringHelper.GetFirstNotEmpty(parent.BrandName, defaultChild.BrandName, defaultChildBrand);

                defaultChildFeatures = !String.IsNullOrEmpty(defaultChild.Features)
                    ? defaultChild.Features.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList()
                    : new List <string>();
                childListPrice   = defaultChild.ListPrice;
                childDepartment  = defaultChild.Department;
                childSize        = defaultChild.Size;
                childStyleString = defaultChild.StyleString;

                if (defaultChild.StyleId.HasValue)
                {
                    firstChildStyle = db.Styles.GetByStyleIdAsDto(defaultChild.StyleId.Value);
                }
            }

            if (parent != null)
            {
                var variationType = ItemExportHelper.GetVariationType(children != null ? children.Select(ch => ch.Color).ToList() : null);

                //For simplicity, w can just use for parent SKU (unless it exist) style-%parentASIN%.
                string parentSku = parent.SKU;
                if (String.IsNullOrEmpty(parentSku))
                {
                    //NOTE: removed ASIN part (I guess it could be used for preventing listings mix)
                    parentSku = childStyleString;// + "-" + parent.ASIN;
                }
                var mainGender   = StringHelper.GetFirstNotEmpty(childDepartment, parent.Department, defaultChildGender);
                var sizeType     = ItemExportHelper.GetSizeType(childSize);
                var categoryInfo = categoryService.GetCategory((MarketType)parent.Market, parent.MarketplaceId, defaultChildItemStyle, mainGender, sizeType);

                //var type = ItemExportHelper.GetItemType(itemStyle);

                var mainItemType   = categoryInfo.Key1;// ItemExportHelper.ItemTypeConverter(childSize ?? "", type, itemStyle, gender);
                var mainDepartment = StringHelper.GetFirstNotEmpty(categoryInfo.Key2, ItemExportHelper.DepartmentConverter(mainGender, mainItemType, sizeType));
                var parentImage    = ItemExportHelper.ImageConverter(StringHelper.GetFirstNotEmpty(
                                                                         parent.LargeImage != null ? parent.LargeImage.Image : null,
                                                                         parent.ImageSource));
                string clothingType = categoryInfo.Key3;

                var searchTerms = (parent.SearchKeywords ?? "").Replace(";", ", ");
                searchTerms = ItemExportHelper.PrepareSearchTerms(searchTerms);

                var mainMsrp = firstChildStyle != null && firstChildStyle.MSRP.HasValue
                    ? firstChildStyle.MSRP.Value.ToString("G")
                    : (childListPrice.HasValue ? Math.Round(childListPrice.Value / 100).ToString("G") : "");

                var mainDescription = firstChildStyle?.Description ?? parent.Description;

                models.Add(new ExcelWFSProductUSViewModel
                {
                    SKU           = parentSku,
                    Title         = parent.AmazonName,
                    ASIN          = parent.ASIN,
                    ProductId     = "ASIN",
                    BrandName     = mainBrandName,
                    Description   = mainDescription,
                    Type          = mainItemType,
                    Update        = "Update",
                    StandardPrice = "",

                    SuggestedPrice = mainMsrp,
                    Currency       = childListPrice.HasValue ? "USD" : "",

                    Quantity = "",

                    KeyProductFeatures1 = defaultChildFeatures.Count > 0 ? defaultChildFeatures[0] : String.Empty,
                    KeyProductFeatures2 = defaultChildFeatures.Count > 1 ? defaultChildFeatures[1] : String.Empty,
                    KeyProductFeatures3 = defaultChildFeatures.Count > 2 ? defaultChildFeatures[2] : String.Empty,
                    KeyProductFeatures4 = defaultChildFeatures.Count > 3 ? defaultChildFeatures[3] : String.Empty,
                    KeyProductFeatures5 = defaultChildFeatures.Count > 4 ? defaultChildFeatures[4] : String.Empty,

                    SearchTerms1 = searchTerms,
                    //SearchTerms1 = searchTermList.Count > 0 ? searchTermList[0] : String.Empty,
                    //SearchTerms2 = searchTermList.Count > 1 ? searchTermList[1] : String.Empty,
                    //SearchTerms3 = searchTermList.Count > 2 ? searchTermList[2] : String.Empty,
                    //SearchTerms4 = searchTermList.Count > 3 ? searchTermList[3] : String.Empty,
                    //SearchTerms5 = searchTermList.Count > 4 ? searchTermList[4] : String.Empty,

                    MainImageURL   = parentImage,
                    Parentage      = ExcelHelper.ParentageParent,
                    VariationTheme = variationType,

                    Department      = mainDepartment,
                    Color           = "",
                    FeedProductType = clothingType,
                });

                foreach (var child in children)
                {
                    var childStyleImages = child.StyleId.HasValue ?
                                           db.StyleImages
                                           .GetAllAsDto()
                                           .Where(im => im.StyleId == child.StyleId.Value &&
                                                  im.Type != (int)StyleImageType.Swatch)
                                           .ToList()
                                           .OrderByDescending(im => ImageHelper.GetSortIndex(im.Category))
                                           .ThenByDescending(im => im.IsDefault)
                                           .ThenBy(im => im.Id)
                                           .ToList()
                            : null;
                    var childStyleGenderValue = child.StyleId.HasValue ? db.StyleFeatureValues.GetAllWithFeature()
                                                .FirstOrDefault(st => st.StyleId == child.StyleId.Value && st.FeatureId == StyleFeatureHelper.GENDER)?.Value : null;
                    var childStyle = child.StyleId.HasValue ? db.Styles.GetByStyleIdAsDto(child.StyleId.Value) : null;

                    var msrp = childStyle != null && childStyle.MSRP.HasValue
                        ? childStyle.MSRP.Value.ToString("G")
                        : (child.ListPrice.HasValue ? Math.Round(child.ListPrice.Value / 100).ToString("G") : "");

                    var description = childStyle?.Description ?? parent.Description;

                    var fbaInfo = fbaItems != null?fbaItems.FirstOrDefault(f => f.SKU == child.SKU) : null;

                    if (exportMode == ExportToExcelMode.FBA)
                    {
                        if (fbaInfo == null)
                        {
                            throw new ArgumentNullException("fbaInfo", "for SKU=" + child.SKU);
                        }
                    }

                    IList <string> features = !String.IsNullOrEmpty(child.Features)
                        ? child.Features.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList()
                        : new List <string>();
                    if (!String.IsNullOrEmpty(childStyle.BulletPoint1))
                    {
                        features = StringHelper.ToArray(childStyle.BulletPoint1,
                                                        childStyle.BulletPoint2,
                                                        childStyle.BulletPoint3,
                                                        childStyle.BulletPoint4,
                                                        childStyle.BulletPoint5);
                    }

                    var childImage = ItemExportHelper.ImageConverter(StringHelper.GetFirstNotEmpty(
                                                                         child.LargeImageUrl,
                                                                         child.ImageUrl));
                    var childImage1 = "";
                    var childImage2 = "";
                    var childImage3 = "";

                    if (useStyleImageMode == UseStyleImageModes.Auto)
                    {
                        if (String.IsNullOrEmpty(childImage))
                        {
                            if (childStyleImages != null && childStyleImages.Any())
                            {
                                childImage = childStyleImages.First().Image;
                            }
                        }
                        else
                        {
                            if (childStyleImages != null && childStyleImages.Any(im => im.Type == (int)StyleImageType.HiRes))
                            {
                                childImage = childStyleImages.First(im => im.Type == (int)StyleImageType.HiRes).Image;
                            }
                        }
                    }
                    if (useStyleImageMode == UseStyleImageModes.StyleImage ||
                        (useStyleImageMode == UseStyleImageModes.ListingImage && String.IsNullOrEmpty(childImage)))
                    {
                        if (childStyleImages != null && childStyleImages.Any())
                        {
                            childImage  = childStyleImages.First().Image;
                            childImage1 = childStyleImages.Count > 1 ? childStyleImages[1].Image : "";
                            childImage2 = childStyleImages.Count > 2 ? childStyleImages[2].Image : "";
                            childImage3 = childStyleImages.Count > 3 ? childStyleImages[3].Image : "";
                        }
                    }
                    if (useStyleImageMode == UseStyleImageModes.ListingImage)
                    {
                        //Nothing
                    }

                    var hasAmazonUpdates = child.IsExistOnAmazon == true;
                    var displaySize      = String.IsNullOrEmpty(child.Size) ? "" : ("Size " + child.Size);
                    models.Add(new ExcelWFSProductUSViewModel
                    {
                        Id              = child.Id,
                        StyleId         = child.StyleId,
                        StyleItemId     = child.StyleItemId,
                        IsExistOnAmazon = hasAmazonUpdates,

                        SKU         = ItemExportHelper.PrepareSKU(child.SKU, exportMode),
                        Title       = hasAmazonUpdates ? child.Name : StringHelper.Join(", ", child.Name, child.Color, displaySize),
                        ASIN        = hasAmazonUpdates ? child.ASIN : child.Barcode,
                        ProductId   = hasAmazonUpdates ? "ASIN" : "UPC",
                        BrandName   = mainBrandName,
                        Description = description,
                        Type        = mainItemType,
                        Update      = hasAmazonUpdates ? "PartialUpdate" : "Update",

                        StandardPrice  = (child.CurrentPrice + (exportMode == ExportToExcelMode.FBA || exportMode == ExportToExcelMode.FBP ? 5 : 0)).ToString("G"),
                        SuggestedPrice = msrp,
                        Currency       = child.ListPrice.HasValue ? "USD" : "",
                        Quantity       = exportMode == ExportToExcelMode.FBA ? fbaInfo.Quantity.ToString("G") : child.RealQuantity.ToString("G"),

                        KeyProductFeatures1 = features.Count > 0 ? features[0] : String.Empty,
                        KeyProductFeatures2 = features.Count > 1 ? features[1] : String.Empty,
                        KeyProductFeatures3 = features.Count > 2 ? features[2] : String.Empty,
                        KeyProductFeatures4 = features.Count > 3 ? features[3] : String.Empty,
                        KeyProductFeatures5 = features.Count > 4 ? features[4] : String.Empty,

                        SearchTerms1 = searchTerms,
                        //SearchTerms1 = searchTermList.Count > 0 ? searchTermList[0] : String.Empty,
                        //SearchTerms2 = searchTermList.Count > 1 ? searchTermList[1] : String.Empty,
                        //SearchTerms3 = searchTermList.Count > 2 ? searchTermList[2] : String.Empty,
                        //SearchTerms4 = searchTermList.Count > 3 ? searchTermList[3] : String.Empty,
                        //SearchTerms5 = searchTermList.Count > 4 ? searchTermList[4] : String.Empty,

                        MainImageURL     = childImage,
                        OtherImageUrl1   = childImage1,
                        OtherImageUrl2   = childImage2,
                        OtherImageUrl3   = childImage3,
                        Parentage        = ExcelHelper.ParentageChild,
                        ParentSKU        = parentSku,
                        RelationshipType = "Variation",
                        VariationTheme   = variationType,
                        Department       = mainDepartment,
                        Color            = child.Color,
                        Size             = child.Size,
                        //SpecialSize = child.SpecialSize,

                        FulfillmentCenterID        = exportMode == ExportToExcelMode.FBA ? "AMAZON_NA" : null,
                        PackageHeight              = exportMode == ExportToExcelMode.FBA && fbaInfo.PackageHeight.HasValue ? fbaInfo.PackageHeight.ToString() : null,
                        PackageWidth               = exportMode == ExportToExcelMode.FBA && fbaInfo.PackageWidth.HasValue ? fbaInfo.PackageWidth.ToString() : null,
                        PackageLength              = exportMode == ExportToExcelMode.FBA && fbaInfo.PackageLength.HasValue ? fbaInfo.PackageLength.ToString() : null,
                        PackageLengthUnitOfMeasure = exportMode == ExportToExcelMode.FBA ? "IN" : null,
                        PackageWeight              = exportMode == ExportToExcelMode.FBA ? child.Weight.ToString() : null,
                        PackageWeightUnitOfMeasure = exportMode == ExportToExcelMode.FBA ? "OZ" : null,

                        SupplierDeclaredDgHzRegulation1 = "Not Applicable",
                        BatteriesRequired = "FALSE",
                        FeedProductType   = clothingType,

                        MerchantShippingGroupName = child.IsPrime ? AmazonTemplateHelper.PrimeTemplate : (child.Weight > 16 ? AmazonTemplateHelper.OversizeTemplate : null),
                    });
                }

                //Copy to parent child Type
                if (children.Count > 0)
                {
                    models[0].Type = models[1].Type;
                }

                if (children.Count > 0 &&
                    useStyleImageMode == UseStyleImageModes.StyleImage)
                {
                    models[0].MainImageURL = models[1].MainImageURL;
                }
            }

            filename = models[0].SKU + "_" + (defaultChildSubLicense != null ? defaultChildSubLicense.Value : "none") + "_US" + Path.GetExtension(USTemplatePath);

            return(models);
        }
Exemplo n.º 11
0
        public ParentItemDTO CreateFromStyle(IUnitOfWork db,
                                             StyleEntireDto style,
                                             MarketType market,
                                             string marketplaceId,
                                             out IList <MessageString> messages)
        {
            messages = new List <MessageString>();

            var styleItems = db.StyleItems.GetByStyleIdWithBarcodesAsDto(style.Id);

            var model = new ParentItemDTO();

            model.ASIN = style.StyleID;

            model.Market        = (int)market;
            model.MarketplaceId = marketplaceId;

            model.AmazonName = style.Name;

            var items = new List <ItemDTO>();

            foreach (var styleItem in styleItems)
            {
                var newItem = new ItemDTO();
                newItem.Market        = (int)market;
                newItem.MarketplaceId = marketplaceId;

                newItem.StyleString = style.StyleID;
                newItem.StyleId     = styleItem.StyleId;
                newItem.StyleItemId = styleItem.StyleItemId;
                newItem.StyleSize   = styleItem.Size;
                newItem.StyleColor  = styleItem.Color;

                newItem.Size  = styleItem.Size;
                newItem.Color = styleItem.Color;

                newItem.Weight = styleItem.Weight;

                var barcode = styleItem.Barcodes?.FirstOrDefault();
                if (barcode != null)
                {
                    newItem.Barcode = barcode.Barcode;
                }

                newItem.CurrentPrice = 0;
                newItem.SKU          = style.StyleID + "-" + SizeHelper.PrepareSizeForSKU(styleItem.Size, false);
                if (!String.IsNullOrEmpty(styleItem.Color))
                {
                    newItem.SKU += "-" + styleItem.Color;
                }

                items.Add(newItem);
            }

            model.Variations = items
                               .OrderBy(si => SizeHelper.GetSizeIndex(si.StyleSize))
                               .ThenBy(si => si.Color)
                               .ToList();

            return(model);
        }