private void SyncProducts() { var productsSource = (from p in Assortment select p); if (productsSource.Count() > 0) { bool doRetailStock = ((ConnectorSystemType)Connector.ConnectorType).Has(ConnectorSystemType.ExportRetailStock); XDocument retailStock = null; Dictionary <int, List <AssortmentRetailStock> > retailStockList = new Dictionary <int, List <AssortmentRetailStock> >(); if (IsPrimaryLanguage && doRetailStock) { retailStockList = (from r in Assortment select new { product_id = r.ProductID, store_records = r.RetailStock }).Distinct().ToDictionary(x => x.product_id, y => y.store_records); } Dictionary <string, int> stockStoreList = new Dictionary <string, int>(); if (doRetailStock) { using (var helper = new AssortmentHelper(Connector.Connection, Version)) { stockStoreList = helper.GetStockStoreList(); } } List <AssortmentStockPriceProduct> products = productsSource.Where(x => !x.IsConfigurable).ToList(); ProcessProductCollection(retailStockList, stockStoreList, products); } if (AssortmentToDeactivate == null && productsSource.Count() > 0) { CheckFullAssortmentAndDeactivateProducts(productsSource); } else { DeactivateAssortmentPartial(AssortmentToDeactivate); } }
private void SyncProducts() { bool doRetailStock = ((ConnectorSystemType)Connector.ConnectorType).Has(ConnectorSystemType.ExportRetailStock); XDocument retailStock = null; Dictionary <int, List <AssortmentRetailStock> > retailStockList = new Dictionary <int, List <AssortmentRetailStock> >(); if (IsPrimaryLanguage && doRetailStock) { retailStockList = (from r in Assortment select new { product_id = r.ProductID, store_records = r.RetailStock }).Distinct().ToDictionary(x => x.product_id, y => y.store_records); } Dictionary <string, int> stockStoreList = new Dictionary <string, int>(); if (doRetailStock) { using (var helper = new AssortmentHelper(Connector.Connection, Version)) { stockStoreList = helper.GetStockStoreList(); } } var productsSource = (from p in Assortment select p); List <AssortmentStockPriceProduct> products = productsSource.Where(x => !x.IsConfigurable).ToList(); ProcessProductCollection(retailStockList, stockStoreList, products); using (var helper = new AssortmentHelper(Connector.Connection, Version)) { var skuList = helper.GetSkuList(); var skuInXmlList = (from p in productsSource select p.ManufacturerID).ToList(); var toDeactivate = skuList.Where(x => !skuInXmlList.Contains(x.Key)); //exclude shipping costs toDeactivate = toDeactivate.Where(x => !x.Key.StartsWith("ShippingCostProductID_")); if (toDeactivate.Count() > 0) { SortedDictionary <string, eav_attribute> attributeList = helper.GetAttributeList(PRODUCT_ENTITY_TYPE_ID); foreach (var p in toDeactivate) { SetProductStatus(p.Value.entity_id, (int)PRODUCT_STATUS.DISABLED, helper, attributeList, StoreList[CurrentStoreCode].store_id); if (RequiresStockUpdate) { helper.SyncStock(new cataloginventory_stock_item() { product_id = p.Value.entity_id, qty = 0, is_in_stock = false }); } } } } }