Sequence contains more than one matching elelment

Posted by Community Admin on 04-Aug-2018 13:06

Sequence contains more than one matching elelment

All Replies

Posted by Community Admin on 25-May-2015 00:00

Hi all,

I am working with sitefinity 7.0.

I have eCommerce  enable in my cms and have some dummy product manually created.

I have created some product by API also.Now when i am clicking the Products menu under eCommerce section, it shows an alert shows ,says that "Sequence contains more than one matching elelment"

I am not able browse any products ?

Given below is the code that i have used?

CatalogManager manager = CatalogManager.GetManager();
            EcommerceManager ecommerceManager = EcommerceManager.GetManager();
            
            foreach (var myProduct in myProducts)
           

                if (manager.GetProducts().Where(t => t.Title == myProduct.Title).SingleOrDefault() != null)
               
                    continue;     // Product already exists
               

                ProductType productType = ecommerceManager.GetProductTypes().Where(t => t.Title == myProduct.ProductTypeName).SingleOrDefault();
                if (productType == null)
               
                    continue;      // Product Type does not exist
               

                Product product = manager.CreateProduct(productType.ClrType);
                product.ClrType = productType.ClrType;

                product.Title = myProduct.Title;
                product.AssociateBuyerWithRole = Guid.Empty;
                product.DateCreated = DateTime.Now;
                product.Description = myProduct.Description;
                //product.IsShippable = myProduct.IsShippable;
                product.Price = myProduct.Price;
                //product.SaleEndDate = myProduct.SaleEndDate;
                //product.SaleStartDate = myProduct.SaleStartDate;
                //product.SalePrice = myProduct.SalePrice;
                product.Sku = myProduct.Sku;
                product.UrlName = Regex.Replace(myProduct.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                product.Visible = true;
                //product.Weight = myProduct.Weight;

                product.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master;

                manager.Provider.RecompileItemUrls(product);
                manager.SaveChanges();

                var contextBag = new Dictionary<string, string>();
                contextBag.Add("ContentType", product.GetType().FullName);

                string workflowOperation = "Publish";

                WorkflowManager.MessageWorkflow(product.Id,
                    product.GetType(),
                    "OpenAccessDataProvider",
                    workflowOperation,
                    false,
                    contextBag);

             
            ​

 Any idea on this?

Posted by Community Admin on 28-May-2015 00:00

Hi Ajai,

I have already provided an answer in the ticket that Anju Raman recently opened. You can check it for more details regarding this issue.

Regards,
Kaloyan
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed