Exemple #1
0
        private void importProductData(string path, ShopifyImportData data)
        {
            try
            {
                foreach (var fileName in Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly))
                {
                    if (!ValidExtensions.Contains(Path.GetExtension(fileName).ToLower()))
                    {
                        continue;
                    }

                    var file      = Path.GetFileNameWithoutExtension(fileName);
                    var splitfile = file.Split('+');

                    var title  = file.Replace("_", " ").Replace("+", ", ");
                    var handle = file.ToLower().Replace("+", "-").Replace("_", "-");

                    for (var i = 0; i < data.Variants.Count; i++)
                    {
                        ShopifyProduct product;
                        if (i == 0)
                        {
                            product = new ShopifyProduct(handle, title, buildHtmlDescription(splitfile, data),
                                                         data.Vendor, data.Type, data.Tags, data.Variants[i].Item1,
                                                         data.Variants[i].Item2,
                                                         data.ImageUrl + Path.GetFileName(fileName));
                        }
                        else
                        {
                            product = new ShopifyProduct(handle, string.Empty, string.Empty,
                                                         string.Empty, string.Empty, new string[] {}, data.Variants[i].Item1,
                                                         data.Variants[i].Item2, string.Empty);
                        }

                        if (!_products.ContainsKey(product.Handle))
                        {
                            _products.Add(product.Handle, product);
                        }
                        else if (data.Variants.Count > 1)
                        {
                            var newHandle = handle;
                            var iterator  = 1;
                            while (_products.ContainsKey(newHandle))
                            {
                                newHandle += string.Format("-variant{0}", iterator++);
                            }
                            _products.Add(newHandle, product);
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Problems importing information");
            }
        }
Exemple #2
0
        private Dictionary <string, ShopifyProduct> csvToShopifyData(IEnumerable <char> csv)
        {
            var shopifyData = new Dictionary <string, ShopifyProduct>();

            foreach (var line in csvLineToArray(csv))
            {
                var shopifyProductOptions = new ShopifyProductOptions(line[6], line[7], line[8], line[9], line[10], line[11]);
                var shopifyVariant        = new ShopifyVariant(line[12], line[13], line[14], line[15], line[16], line[17], line[18],
                                                               line[17], line[18], line[19]);
                var product = new ShopifyProduct(line[0], line[1], line[2], line[3], line[4], line[5].Split(','), shopifyProductOptions, shopifyVariant, line[line.Length - 1]);
                shopifyData.Add(product.Handle, product);
            }

            return(shopifyData);
        }
        private void populateDetailsPanel(ShopifyProduct product)
        {
            _productNameTb.Text          = product.Title;
            _productDescTb.Text          = product.Details;
            _productPriceTb.Text         = product.Price;
            _vendorComboBox.SelectedItem = product.Vendor;
            _typeComboBox.SelectedItem   = product.Type;
            _imageUrlTb.Text             = product.ImageSource;
            clearTagsClb();

            foreach (var tag in product.Tags)
            {
                for (var i = 0; i < _tagsCLB.Items.Count; i++)
                {
                    if ((string)_tagsCLB.Items[i] == tag)
                    {
                        _tagsCLB.SetItemChecked(i, true);
                    }
                }
            }
        }
        private void populateDetailsPanel(ShopifyProduct product)
        {
            _productNameTb.Text = product.Title;
            _productDescTb.Text = product.Details;
            _productPriceTb.Text = product.Price;
            _vendorComboBox.SelectedItem = product.Vendor;
            _typeComboBox.SelectedItem = product.Type;
            _imageUrlTb.Text = product.ImageSource;
            clearTagsClb();

            foreach (var tag in product.Tags)
            {
                for (var i = 0; i < _tagsCLB.Items.Count; i++)
                {
                    if ((string)_tagsCLB.Items[i] == tag)
                    {
                        _tagsCLB.SetItemChecked(i, true);
                    }
                }
            }
        }
        private void importProductData(string path, ShopifyImportData data)
        {
            try
            {
                foreach (var fileName in Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly))
                {
                    if (!ValidExtensions.Contains(Path.GetExtension(fileName).ToLower()))
                    {
                        continue;
                    }

                    var file = Path.GetFileNameWithoutExtension(fileName);
                    var splitfile = file.Split('+');

                    var title = file.Replace("_", " ").Replace("+", ", ");
                    var handle = file.ToLower().Replace("+", "-").Replace("_", "-");

                    for (var i = 0; i < data.Variants.Count; i++)
                    {
                        ShopifyProduct product;
                        if (i == 0)
                        {
                            product = new ShopifyProduct(handle, title, buildHtmlDescription(splitfile, data),
                                                             data.Vendor, data.Type, data.Tags, data.Variants[i].Item1,
                                                             data.Variants[i].Item2,
                                                             data.ImageUrl + Path.GetFileName(fileName));
                        }
                        else
                        {
                            product = new ShopifyProduct(handle, string.Empty, string.Empty,
                                 string.Empty, string.Empty, new string[] {}, data.Variants[i].Item1,
                                 data.Variants[i].Item2, string.Empty);
                        }

                        if (!_products.ContainsKey(product.Handle))
                        {
                            _products.Add(product.Handle, product);
                        }
                        else if (data.Variants.Count > 1)
                        {
                            var newHandle = handle;
                            var iterator = 1;
                            while (_products.ContainsKey(newHandle))
                            {
                                newHandle += string.Format("-variant{0}", iterator++);
                            }
                            _products.Add(newHandle, product);
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Problems importing information");
            }
        }
        private Dictionary<string, ShopifyProduct> csvToShopifyData(IEnumerable<char> csv)
        {
            var shopifyData = new Dictionary<string, ShopifyProduct>();

            foreach(var line in csvLineToArray(csv))
            {
                var shopifyProductOptions = new ShopifyProductOptions(line[6], line[7], line[8], line[9], line[10], line[11]);
                var shopifyVariant = new ShopifyVariant(line[12], line[13], line[14], line[15], line[16], line[17], line[18],
                                                        line[17], line[18], line[19]);
                var product = new ShopifyProduct(line[0], line[1], line[2], line[3], line[4], line[5].Split(','), shopifyProductOptions, shopifyVariant, line[line.Length - 1]);
                shopifyData.Add(product.Handle, product);
            }

            return shopifyData;
        }