Exemplo n.º 1
0
        //public void Exec(Int32 CategorySend)
        //{
        //    try
        //    {
        //        if (CategorySend != 1)
        //        {
        //            CatalogRepository CatalogRepository = new CatalogRepository();
        //            if (CatalogRepository.ExistPre_Id(CategorySend) == false)
        //            {
        //                PsCategoryLangRepository PsCategoryLangRepository = new PsCategoryLangRepository();
        //                if (PsCategoryLangRepository.ExistCategoryLang(CategorySend, Core.Global.Lang))
        //                {
        //                    PsCategoryRepository PsCategoryRepository = new PsCategoryRepository();
        //                    PsCategory PsCategory = PsCategoryRepository.ReadId(CategorySend);
        //                    PsCategoryLang PsCategoryLang = PsCategoryLangRepository.ReadCategoryLang(CategorySend, Core.Global.Lang);


        //                    F_CATALOGUERepository F_CATALOGUERepository = new F_CATALOGUERepository();
        //                    if (F_CATALOGUERepository.ExistIntituleNiveau(PsCategoryLang.Name, Convert.ToInt16(PsCategory.LevelDepth - 1)))
        //                    {
        //                        F_CATALOGUE F_CATALOGUE = F_CATALOGUERepository.ReadIntituleNiveau(PsCategoryLang.Name, Convert.ToInt16(PsCategory.LevelDepth - 1));
        //                        Catalog Catalog = new Catalog()
        //                        {
        //                            Cat_Name = PsCategoryLang.Name,
        //                            Cat_Description = PsCategoryLang.Description,
        //                            Cat_Level = PsCategory.LevelDepth,
        //                            Cat_MetaTitle = PsCategoryLang.MetaTitle,
        //                            Cat_MetaKeyword = PsCategoryLang.MetaKeywords,
        //                            Cat_Active = Convert.ToBoolean(PsCategory.Active),
        //                            Cat_MetaDescription = PsCategoryLang.MetaDescription,
        //                            Cat_LinkRewrite = PsCategoryLang.LinkRewrite,
        //                            Cat_Sync = true,
        //                            Cat_Date = PsCategory.DateUpd,
        //                            Sag_Id = F_CATALOGUE.cbMarq,
        //                            Pre_Id = Convert.ToInt32(PsCategory.IDCategory)
        //                        };

        //                        if (PsCategory.IDParent != 0 && PsCategory.IDParent != 1)
        //                        {
        //                            if (PsCategoryRepository.ExistId(Convert.ToInt32(PsCategory.IDParent)))
        //                            {
        //                                PsCategory PsCategoryParent = PsCategoryRepository.ReadId(Convert.ToInt32(PsCategory.IDParent));
        //                                if (CatalogRepository.ExistPre_Id(Convert.ToInt32(PsCategoryParent.IDCategory)))
        //                                {
        //                                    Catalog CatalogParent = CatalogRepository.ReadPre_Id(Convert.ToInt32(PsCategoryParent.IDCategory));
        //                                    Catalog.Cat_Parent = CatalogParent.Cat_Id;
        //                                }
        //                            }
        //                        }
        //                        CatalogRepository.Add(Catalog);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Core.Error.SendMailError(ex.ToString());
        //    }
        //}


        //public void Exec(Int32 CategorySend)
        //{
        //    try
        //    {
        //        if (CategorySend != 1)
        //        {
        //            CatalogRepository catalogs = new CatalogRepository();

        //            //Vérifie si le catalogue PS est référence dans PC
        //            if (!catalogs.ExistPre_Id(CategorySend))
        //            {
        //                PsCategoryLangRepository langs = new PsCategoryLangRepository();

        //                //Vérifie que le catalogue existe bien dans la langue définit dans PC
        //                if (langs.ExistCategoryLang(CategorySend, Global.Lang,Global.CurrentShop.IDShop))
        //                {
        //                    PsCategoryRepository categories = new PsCategoryRepository();

        //                    //Récupération du catalogue dans PS
        //                    PsCategory category = categories.ReadId(CategorySend);
        //                    PsCategoryLang lang = langs.ReadCategoryLang(CategorySend, Global.Lang, Global.CurrentShop.IDShop);

        //                    //Récupération de tous les catalogues S suceptible de correspondre au catalogue PS
        //                    List<F_CATALOGUE> correspondances = new List<F_CATALOGUE>(
        //                        new F_CATALOGUERepository().ReadIntituleNiveau(lang.Name, Convert.ToInt16(category.LevelDepth - 1)));

        //                    if (correspondances.Count > 0)
        //                    {
        //                        PsCategory parentPrestashop = null;

        //                        //Récupération du parent dans PS
        //                        //Le catalogue 1 correspond à au noeud racine "Accueil" dans PS (il n'est ni utilisable, ni supprimable, ni exportable)
        //                        if (category.IDParent != 0 && category.IDParent != 1)
        //                            parentPrestashop = categories.ReadId(Convert.ToInt32(category.IDParent));

        //                        Catalog nouveauCatalogue = null;

        //                        if (correspondances.Count == 1)
        //                            nouveauCatalogue = GetCatalogue(category, lang, correspondances[0].cbMarq);
        //                        else if (correspondances.Count > 1)
        //                            foreach (var correspondanceSage in correspondances)
        //                                if (correspondanceSage.CL_NoParent.HasValue)
        //                                {
        //                                    //Récupération de la référence au parent de la correspondance en cours dans PC
        //                                    Catalog parentCorrespondance = catalogs.ReadSag_Id(correspondanceSage.CL_NoParent.Value);

        //                                    //Comparaison de l'ID de la réf PS du parent de la correspondance avec l'id du parent PS.
        //                                    if (parentCorrespondance != null)
        //                                        if (parentCorrespondance.Pre_Id == parentPrestashop.IDCategory)
        //                                        {
        //                                            nouveauCatalogue = GetCatalogue(category, lang, correspondanceSage.cbMarq);
        //                                            break;
        //                                        }
        //                                }

        //                        if (nouveauCatalogue != null && parentPrestashop != null)
        //                        {
        //                            //Si l'identifiant PS du parent existe dans PC
        //                            if (catalogs.ExistPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)))
        //                                nouveauCatalogue.Cat_Parent = catalogs.ReadPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)).Sag_Id;
        //                        }

        //                        catalogs.Add(nouveauCatalogue);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Core.Error.SendMailError(ex.ToString());
        //    }
        //}


        public void Exec(Int32 CategorySend)
        {
            try
            {
                if (CategorySend != Core.Global.CurrentShop.IDCategory)
                {
                    Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository();

                    //Vérifie si le catalogue PS est référence dans PC
                    if (!CatalogRepository.ExistPre_Id(CategorySend))
                    {
                        Model.Prestashop.PsCategoryLangRepository PsCategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository();

                        //Vérifie que le catalogue existe bien dans la langue définit dans PC
                        if (PsCategoryLangRepository.ExistCategoryLang(CategorySend, Global.Lang, Core.Global.CurrentShop.IDShop))
                        {
                            Model.Prestashop.PsCategoryRepository PsCategoryRepository = new Model.Prestashop.PsCategoryRepository();

                            //Récupération du catalogue dans PS
                            Model.Prestashop.PsCategory     PsCategory     = PsCategoryRepository.ReadId((UInt32)CategorySend);
                            Model.Prestashop.PsCategoryLang PsCategoryLang = PsCategoryLangRepository.ReadCategoryLang(CategorySend, Global.Lang, Core.Global.CurrentShop.IDShop);

                            Model.Prestashop.PsCategory parentPrestashop = null;

                            //Récupération du parent dans PS
                            //Le catalogue 1 correspond à au noeud racine "Accueil" dans PS (il n'est ni utilisable, ni supprimable, ni exportable)
                            if (PsCategory.IDParent != 0 && PsCategory.IDParent != 1 && PsCategory.IDParent != Core.Global.CurrentShop.IDShop)
                            {
                                parentPrestashop = PsCategoryRepository.ReadId(PsCategory.IDParent);
                            }

                            Model.Local.Catalog nouveauCatalogue = GetCatalogue(PsCategory, PsCategoryLang, 0);

                            if (nouveauCatalogue != null && parentPrestashop != null)
                            {
                                //Si l'identifiant PS du parent existe dans PC
                                if (CatalogRepository.ExistPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)))
                                {
                                    nouveauCatalogue.Cat_Parent = CatalogRepository.ReadPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)).Cat_Id;
                                }
                            }

                            CatalogRepository.Add(nouveauCatalogue);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void AssignCatalogProduct(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Local.ArticleRepository ArticleRepository)
        {
            try
            {
                Model.Local.ArticleCatalogRepository         ArticleCatalogRepository    = new Model.Local.ArticleCatalogRepository();
                Model.Local.CatalogRepository                CatalogRepository           = new Model.Local.CatalogRepository();
                Model.Prestashop.PsCategoryProductRepository PsCategoryProductRepository = new Model.Prestashop.PsCategoryProductRepository();
                Model.Prestashop.PsCategoryRepository        PsCategoryRepository        = new Model.Prestashop.PsCategoryRepository();

                // filtrage des catalogues existants dans PC et PS
                List <Model.Local.CatalogLight> ListLocalCatalog = CatalogRepository.ListLight();
                List <uint> ListPrestashopCategory = PsCategoryRepository.ListIdOrderByLevelDepth(Core.Global.CurrentShop.IDShop, PsCategoryRepository.ReadId(Core.Global.CurrentShop.IDCategory).LevelDepth);
                ListLocalCatalog = ListLocalCatalog.Where(lc => ListPrestashopCategory.Count(pc => pc == (uint)lc.Pre_Id) > 0).ToList();

                // filtrage des associations PS par rapport aux catégories PS existantes en tant que catalogue PC
                List <Model.Prestashop.PsCategoryProduct> ListPsCategoryProduct = PsCategoryProductRepository.ListProduct(Product.IDProduct);
                ListPsCategoryProduct = ListPsCategoryProduct.Where(cp => ListLocalCatalog.Count(lc => lc.Pre_Id == cp.IDCategory) > 0).ToList();

                // filtrage des associations PC par rapport aux catégories ayant un ID PS
                List <Model.Local.ArticleCatalog> ListLocal = ArticleCatalogRepository.ListArticle(Article.Art_Id);
                ListLocal = ListLocal.Where(ac => ac.Catalog.Pre_Id != null).ToList();

                if (Core.Global.GetConfig().DeleteCatalogProductAssociation)
                {
                    // suppressions des associations inexistantes dans PC
                    while (ListPsCategoryProduct.Count(cp => ListLocal.Count(ac => ac.Catalog.Pre_Id == cp.IDCategory) == 0) > 0)
                    {
                        Model.Prestashop.PsCategoryProduct target = ListPsCategoryProduct.FirstOrDefault(cp => ListLocal.Count(ac => ac.Catalog.Pre_Id == cp.IDCategory) == 0);
                        PsCategoryProductRepository.Delete(target);
                        ListPsCategoryProduct.Remove(target);
                    }
                    ;
                }

                ListLocal = ListLocal.Where(ac => ListPsCategoryProduct.Count(cp => cp.IDCategory == ac.Catalog.Pre_Id) == 0).ToList();
                foreach (Model.Local.ArticleCatalog ArticleCatalog in ListLocal)
                {
                    uint IDCategory = (UInt32)ArticleCatalog.Catalog.Pre_Id;
                    PsCategoryProductRepository.Add(new Model.Prestashop.PsCategoryProduct()
                    {
                        IDProduct  = Product.IDProduct,
                        IDCategory = IDCategory,
                        Position   = Model.Prestashop.PsCategoryProductRepository.NextPositionProductCatalog(IDCategory),
                    });
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }
        public void DeleteCatalog(Model.Local.Catalog catalog)
        {
            Model.Local.ArticleCatalogRepository ArticleCatalogRepository =
                new Model.Local.ArticleCatalogRepository();

            //Suppression de tous les liens articles
            foreach (var articleCatalog in ArticleCatalogRepository.ListCatalog(catalog.Cat_Id))
            {
                ArticleCatalogRepository.Delete(articleCatalog);
            }

            //Suppression image
            Model.Local.CatalogImageRepository CatalogImageRepository = new Model.Local.CatalogImageRepository();
            if (catalog.CatalogImage != null && catalog.CatalogImage.Count > 0)
            {
                foreach (Model.Local.CatalogImage catalogimage in CatalogImageRepository.ListCatalog(catalog.Cat_Id))
                {
                    catalogimage.EraseFiles();
                    CatalogImageRepository.Delete(catalogimage);
                }
            }

            CatalogRepository.Delete(catalog);

            // <JG> 04/02/2013 ajout de la tentative de suppression du catalogue Prestashop
            try
            {
                if (catalog.Pre_Id != null)
                {
                    Model.Prestashop.PsCategoryRepository PsCategoryRepository = new Model.Prestashop.PsCategoryRepository();
                    if (PsCategoryRepository.ExistId((int)catalog.Pre_Id))
                    {
                        PsCategoryRepository.Delete(PsCategoryRepository.ReadId((UInt32)catalog.Pre_Id));

                        Core.Global.LaunchAlternetis_RegenerateCategoryTree();
                        Core.Global.LaunchAlternetis_ClearSmartyCache();
                    }
                }
            }
            catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); }

            this.LoadCatalogs();
        }
        public void Exec(Int32 CatalogSend)
        {
            try
            {
                Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository();
                Model.Local.Catalog           Catalog           = CatalogRepository.ReadId(CatalogSend);
                // if the catalog have a parent
                Boolean isSync   = false;
                uint    IdParent = 0;
                if (Catalog.Cat_Parent != 0)
                {
                    if (CatalogRepository.ExistId(Catalog.Cat_Parent))
                    {
                        Model.Local.Catalog CatalogParent = CatalogRepository.ReadId(Catalog.Cat_Parent);
                        if (CatalogParent.Pre_Id != null && CatalogParent.Pre_Id != 0)
                        {
                            IdParent = (uint)CatalogParent.Pre_Id.Value;
                            isSync   = true;
                        }
                    }
                }
                // default IdParent is defined on shop in Prestashop
                else
                {
                    isSync   = true;
                    IdParent = Global.CurrentShop.IDCategory;
                }


                if (isSync == true)
                {
                    Boolean isCategory = false;
                    Model.Prestashop.PsCategory           Category           = new Model.Prestashop.PsCategory();
                    Model.Prestashop.PsCategoryRepository CategoryRepository = new Model.Prestashop.PsCategoryRepository();
                    // If the Catalog have a connection with Prestashop
                    if (Catalog.Pre_Id != null)
                    {
                        Catalog.Cat_Date = Catalog.Cat_Date.AddMilliseconds(-Catalog.Cat_Date.Millisecond);
                        if (CategoryRepository.ExistId(Catalog.Pre_Id.Value))
                        {
                            Category   = CategoryRepository.ReadId((UInt32)Catalog.Pre_Id.Value);
                            isCategory = true;

                            if (Category.DateUpd.Ticks > Catalog.Cat_Date.Ticks)
                            {
                                this.ExecDistantLocal(Category, Catalog, CatalogRepository);
                            }
                            else if (Category.DateUpd.Ticks < Catalog.Cat_Date.Ticks)
                            {
                                this.ExecLocalDistant(Catalog, Category, CatalogRepository, CategoryRepository, isCategory, IdParent);
                            }
                            else
                            {
                                ExecGroupsLocalDistant(Category);
                            }
                        }
                    }
                    // We need to sync Catalog with Category
                    else
                    {
                        this.ExecLocalDistant(Catalog, Category, CatalogRepository, CategoryRepository, isCategory, IdParent);
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }
        private void ExecLocalDistant(Model.Local.Catalog Catalog, Model.Prestashop.PsCategory Category, Model.Local.CatalogRepository CatalogRepository, Model.Prestashop.PsCategoryRepository CategoryRepository, Boolean isCategory, uint IdParent)
        {
            try
            {
                bool flag_move = (Category.IDParent != IdParent);

                Core.Temp.SyncCatalogue_ClearSmartyCache = true;
                Core.Temp.SyncCatalogue_RegenerateTree   = true;
                // Assign data from Catalog to Category
                //Category.Position = (uint)Catalog.Cat_Position;
                Category.Active     = Convert.ToByte(Catalog.Cat_Active);
                Category.LevelDepth = (Byte)Catalog.Cat_Level;
                Category.IDParent   = IdParent;
                Category.DateUpd    = Catalog.Cat_Date;
                // use cron for function "regenerateEntireNtree"
                //Category.NLeft = CategoryRepository.ReadId(IdParent).NLeft;
                //Category.NRight = CategoryRepository.ReadId(IdParent).NRight;
                Category.IDShopDefault = Global.CurrentShop.IDShop;
                if (isCategory == false)
                {
                    Category.DateAdd        = Category.DateUpd;
                    Category.IsRootCategory = Convert.ToSByte(false);
                    Category.Position       = 0;
                    CategoryRepository.Add(Category, Global.CurrentShop.IDShop);
                    // We assign the CategoryId to Catalog
                    Catalog.Pre_Id = (Int32)Category.IDCategory;
                    CatalogRepository.Save();
                }
                else
                {
                    CategoryRepository.Save();

                    if (flag_move)
                    {
                        Model.Prestashop.PsCategoryShopRepository PsCategoryShopRepository = new Model.Prestashop.PsCategoryShopRepository();
                        if (PsCategoryShopRepository.ExistCategoryShop(Category.IDCategory, Core.Global.CurrentShop.IDShop))
                        {
                            Model.Prestashop.PsCategoryShop PsCategoryShop = PsCategoryShopRepository.ReadCategoryShop(Category.IDCategory, Core.Global.CurrentShop.IDShop);
                            PsCategoryShop.Position = new Model.Prestashop.PsCategoryRepository().ReadNextPosition(1, Category, (uint)Core.Global.CurrentShop.IDShop);
                            PsCategoryShopRepository.Save();

                            Category.Position = PsCategoryShop.Position;
                            CategoryRepository.Save();
                        }
                    }
                }

                // We need to update CategoryLang too
                Boolean isCategoryLang = false;
                Model.Prestashop.PsCategoryLangRepository CategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository();
                Model.Prestashop.PsCategoryLang           CategoryLang           = new Model.Prestashop.PsCategoryLang();
                if (CategoryLangRepository.ExistCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop))
                {
                    CategoryLang   = CategoryLangRepository.ReadCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop);
                    isCategoryLang = true;
                }
                CategoryLang.Name            = Core.Global.RemovePurge(Catalog.Cat_Name, 128);
                CategoryLang.Description     = Catalog.Cat_Description;
                CategoryLang.LinkRewrite     = Core.Global.ReadLinkRewrite(Catalog.Cat_LinkRewrite);
                CategoryLang.MetaTitle       = Core.Global.RemovePurge(Catalog.Cat_MetaTitle, 70);
                CategoryLang.MetaDescription = Core.Global.RemovePurge(Catalog.Cat_MetaDescription, 160);
                CategoryLang.MetaKeywords    = Core.Global.RemovePurgeMeta(Catalog.Cat_MetaKeyword, 255);

                if (isCategoryLang == false)
                {
                    CategoryLang.IDShop     = Global.CurrentShop.IDShop;
                    CategoryLang.IDLang     = (uint)Core.Global.Lang;
                    CategoryLang.IDCategory = Category.IDCategory;
                    CategoryLangRepository.Add(CategoryLang);
                }
                else
                {
                    CategoryLangRepository.Save();
                }


                // <JG> 26/12/2012 ajout insertion autres langues actives si non renseignées
                try
                {
                    Model.Prestashop.PsLangRepository PsLangRepository = new Model.Prestashop.PsLangRepository();
                    foreach (Model.Prestashop.PsLang PsLang in PsLangRepository.ListActive(1, Global.CurrentShop.IDShop))
                    {
                        if (!CategoryLangRepository.ExistCategoryLang((int)Category.IDCategory, PsLang.IDLang, Global.CurrentShop.IDShop))
                        {
                            CategoryLang                 = new Model.Prestashop.PsCategoryLang();
                            CategoryLang.IDShop          = Global.CurrentShop.IDShop;
                            CategoryLang.IDCategory      = Category.IDCategory;
                            CategoryLang.IDLang          = PsLang.IDLang;
                            CategoryLang.Name            = Core.Global.RemovePurge(Catalog.Cat_Name, 128);
                            CategoryLang.Description     = Catalog.Cat_Description;
                            CategoryLang.LinkRewrite     = Core.Global.ReadLinkRewrite(Catalog.Cat_LinkRewrite);
                            CategoryLang.MetaTitle       = Core.Global.RemovePurge(Catalog.Cat_MetaTitle, 70);
                            CategoryLang.MetaDescription = Core.Global.RemovePurge(Catalog.Cat_MetaDescription, 160);
                            CategoryLang.MetaKeywords    = Core.Global.RemovePurgeMeta(Catalog.Cat_MetaKeyword, 255);
                            CategoryLangRepository.Add(CategoryLang);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Core.Error.SendMailError(ex.ToString());
                }

                this.ExecGroupsLocalDistant(Category);

                // We need to send pictures
                this.ExecLocalDistantImage(Catalog, Category);
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }
Exemplo n.º 6
0
        private void ExecDistantToLocal(Model.Prestashop.PsProduct Product, Model.Local.Article Article, Model.Local.ArticleRepository ArticleRepository)
        {
            try
            {
                #region Recovery Data From CategoryProduct
                Model.Prestashop.PsCategoryProductRepository PsCategoryProductRepository = new Model.Prestashop.PsCategoryProductRepository();
                Model.Local.CatalogRepository         CatalogRepository        = new Model.Local.CatalogRepository();
                Model.Local.ArticleCatalogRepository  ArticleCatalogRepository = new Model.Local.ArticleCatalogRepository();
                Model.Prestashop.PsCategoryRepository PsCategoryRepository     = new Model.Prestashop.PsCategoryRepository();

                // filtrage des catalogues existants dans PC et PS
                List <Model.Local.CatalogLight> ListLocalCatalog = CatalogRepository.ListLight();
                List <uint> ListPrestashopCategory = PsCategoryRepository.ListIdOrderByLevelDepth(Core.Global.CurrentShop.IDShop, PsCategoryRepository.ReadId(Core.Global.CurrentShop.IDCategory).LevelDepth);
                ListLocalCatalog = ListLocalCatalog.Where(lc => ListPrestashopCategory.Count(pc => pc == (uint)lc.Pre_Id) > 0).ToList();

                // filtrage des associations PS par rapport aux catégories PS existantes en tant que catalogue PC
                List <Model.Prestashop.PsCategoryProduct> ListPsCategoryProduct = PsCategoryProductRepository.ListProduct(Product.IDProduct);
                ListPsCategoryProduct = ListPsCategoryProduct.Where(cp => ListLocalCatalog.Count(lc => lc.Pre_Id == cp.IDCategory) > 0).ToList();

                // filtrage des associations PC par rapport aux catégories ayant un ID PS
                List <Model.Local.ArticleCatalog> ListLocal = ArticleCatalogRepository.ListArticle(Article.Art_Id);
                ListLocal = ListLocal.Where(ac => ac.Catalog.Pre_Id != null).ToList();

                // tant que les associations en local contiennent des associations non présentes dans Prestashop
                if (Core.Global.GetConfig().DeleteCatalogProductAssociation)
                {
                    // suppression des occurences inexistantes dans PS
                    while (ListLocal.Count(ac => ListPsCategoryProduct.Count(cp => cp.IDCategory == ac.Catalog.Pre_Id) == 0) > 0)
                    {
                        Model.Local.ArticleCatalog target = ListLocal.FirstOrDefault(ac => ListPsCategoryProduct.Count(cp => cp.IDCategory == ac.Catalog.Pre_Id) == 0);
                        ArticleCatalogRepository.Delete(target);
                        ListLocal.Remove(target);
                    }
                    ;
                }

                // récupération catégorie principale si catalogue existant dans Prestaconnect
                if (Product.IDCategoryDefault != null && Product.IDCategoryDefault != 0 &&
                    ListLocalCatalog.Count(lc => lc.Pre_Id == (int)Product.IDCategoryDefault) > 0)
                {
                    ArticleRepository = new Model.Local.ArticleRepository();
                    Article           = ArticleRepository.ReadArticle(Article.Art_Id);

                    Article.Cat_Id = ListLocalCatalog.FirstOrDefault(lc => lc.Pre_Id == (int)Product.IDCategoryDefault).Cat_Id;
                    ArticleRepository.Save();

                    if (ListLocal.Count(ac => ac.Art_Id == Article.Art_Id && ac.Cat_Id == Article.Cat_Id) == 0)
                    {
                        ArticleCatalogRepository.Add(new Model.Local.ArticleCatalog()
                        {
                            Art_Id = Article.Art_Id,
                            Cat_Id = Article.Cat_Id
                        });
                    }
                }

                // filtre des associations Prestashop par rapport à celles déjà présentes dans Prestaconnect puis ajout
                ListLocal             = ArticleCatalogRepository.ListArticle(Article.Art_Id);
                ListLocal             = ListLocal.Where(ac => ac.Catalog.Pre_Id != null).ToList();
                ListPsCategoryProduct = ListPsCategoryProduct.Where(cp => ListLocal.Count(ac => ac.Catalog.Pre_Id == (Int32)cp.IDCategory) == 0).ToList();
                foreach (Model.Prestashop.PsCategoryProduct PsCategoryProduct in ListPsCategoryProduct)
                {
                    ArticleCatalogRepository.Add(new Model.Local.ArticleCatalog()
                    {
                        Art_Id = Article.Art_Id,
                        Cat_Id = ListLocalCatalog.FirstOrDefault(lc => lc.Pre_Id == (Int32)PsCategoryProduct.IDCategory).Cat_Id
                    });
                }
                #endregion
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }