private void ExecConditioning(Model.Local.Article Article, Model.Prestashop.PsProduct PsProduct, Model.Sage.F_TAXE TaxeTVA, Model.Prestashop.PsProductRepository PsProductRepository) { try { Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); if (F_ARTICLERepository.ExistArticle(Article.Sag_Id)) { Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id); Model.Local.ConditioningGroupRepository ConditioningGroupRepository = new Model.Local.ConditioningGroupRepository(); Model.Prestashop.PsAttributeGroupRepository PsAttributeGroupRepository = new Model.Prestashop.PsAttributeGroupRepository(); Boolean isProductAttribute; if (F_ARTICLE.AR_Condition != null && F_ARTICLE.AR_Condition != 0 && ConditioningGroupRepository.ExistSage((int)F_ARTICLE.AR_Condition) && PsAttributeGroupRepository.ExistAttributeGroup((uint)ConditioningGroupRepository.ReadSage((int)F_ARTICLE.AR_Condition).Pre_Id)) { Model.Local.ConditioningArticleRepository ConditioningArticleRepository = new Model.Local.ConditioningArticleRepository(); List <Model.Local.ConditioningArticle> ListConditioningArticle = ConditioningArticleRepository.ListArticleSync(Article.Art_Id, true); Model.Prestashop.PsProductAttributeRepository PsProductAttributeRepository = new Model.Prestashop.PsProductAttributeRepository(); Model.Prestashop.PsProductAttribute PsProductAttribute; int stockmaxunity = 0; foreach (Model.Local.ConditioningArticle ConditioningArticle in ListConditioningArticle) { if (ConditioningArticle.EnumereF_CONDITION != null) { PsProductAttribute = new Model.Prestashop.PsProductAttribute(); isProductAttribute = false; if (ConditioningArticle.Pre_Id != null && ConditioningArticle.Pre_Id != 0) { if (PsProductAttributeRepository.ExistProductAttribute((UInt32)ConditioningArticle.Pre_Id)) { PsProductAttribute = PsProductAttributeRepository.ReadProductAttribute((UInt32)ConditioningArticle.Pre_Id); isProductAttribute = true; } } if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightConditioning(PsProduct, PsProductAttribute, ConditioningArticle.EnumereF_CONDITION); } SynchronisationArticle.ReadQuantityConditioning(PsProductAttribute, F_ARTICLE, ConditioningArticle.EnumereF_CONDITION); if (Core.Global.GetConfig().LimiteStockConditionnement&& PsProductAttribute.Quantity >= stockmaxunity) { stockmaxunity = PsProductAttribute.Quantity; PsProduct.Quantity = stockmaxunity; PsProductRepository.Save(); } // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceConditioning(PsProduct, PsProductAttribute, F_ARTICLE, ConditioningArticle.EnumereF_CONDITION, TaxeTVA); } //PsProductAttribute.DefaultOn = (ConditioningArticle.ConArt_Default) ? (byte)1 : (byte)0; if (isProductAttribute == true) { PsProductAttributeRepository.Save(); SynchronisationArticle.ExecShopProductAttribute(PsProductAttribute); SynchronisationArticle.WriteStockAvailableProductAttribute(PsProduct, PsProductAttribute); } } } PsProductAttributeRepository.WriteDate(PsProduct.IDProduct); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecAttribute(Model.Local.Article Article, Model.Prestashop.PsProduct PsProduct, Model.Sage.F_TAXE TaxeTVA, Model.Prestashop.PsProductRepository PsProductRepository) { try { Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); if (F_ARTICLERepository.ExistArticle(Article.Sag_Id)) { Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id); Model.Local.AttributeGroupRepository AttributeGroupRepository = new Model.Local.AttributeGroupRepository(); Model.Prestashop.PsAttributeGroupRepository PsAttributeGroupRepository = new Model.Prestashop.PsAttributeGroupRepository(); Boolean isProductAttribute; if (F_ARTICLE.AR_Gamme1 != null && F_ARTICLE.AR_Gamme1 != 0 && AttributeGroupRepository.ExistSage((int)F_ARTICLE.AR_Gamme1) && PsAttributeGroupRepository.ExistAttributeGroup((uint)AttributeGroupRepository.ReadSage((int)F_ARTICLE.AR_Gamme1).Pre_Id) && ((F_ARTICLE.AR_Gamme2 == null || F_ARTICLE.AR_Gamme2 == 0) || (AttributeGroupRepository.ExistSage((int)F_ARTICLE.AR_Gamme2) && PsAttributeGroupRepository.ExistAttributeGroup((uint)AttributeGroupRepository.ReadSage((int)F_ARTICLE.AR_Gamme2).Pre_Id)))) { Model.Local.AttributeArticleRepository AttributeArticleRepository = new Model.Local.AttributeArticleRepository(); List <Model.Local.AttributeArticle> ListAttributeArticle = AttributeArticleRepository.ListArticleSync(Article.Art_Id, true); Model.Prestashop.PsProductAttributeRepository PsProductAttributeRepository = new Model.Prestashop.PsProductAttributeRepository(); Model.Prestashop.PsProductAttribute PsProductAttribute; int CumulStockGammes = 0; foreach (Model.Local.AttributeArticle AttributeArticle in ListAttributeArticle) { if (AttributeArticle.EnumereF_ARTENUMREF != null) { PsProductAttribute = new Model.Prestashop.PsProductAttribute(); isProductAttribute = false; if (AttributeArticle.Pre_Id != null && AttributeArticle.Pre_Id != 0) { if (PsProductAttributeRepository.ExistProductAttribute((UInt32)AttributeArticle.Pre_Id)) { PsProductAttribute = PsProductAttributeRepository.ReadProductAttribute((UInt32)AttributeArticle.Pre_Id); isProductAttribute = true; } } if (isProductAttribute == true) { if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightAttribute(PsProduct, PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1); } SynchronisationArticle.ReadQuantityAttribute(PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1, AttributeArticle.EnumereGamme2); CumulStockGammes += PsProductAttribute.Quantity; // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceAttribute(PsProduct, PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1, AttributeArticle.EnumereGamme2, TaxeTVA); } PsProductAttributeRepository.Save(); SynchronisationArticle.ExecShopProductAttribute(PsProductAttribute); SynchronisationArticle.WriteStockAvailableProductAttribute(PsProduct, PsProductAttribute); } } } if (PsProduct.Quantity != CumulStockGammes) { PsProduct.Quantity = CumulStockGammes; PsProductRepository.Save(); } PsProductAttributeRepository.WriteDate(PsProduct.IDProduct); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }