コード例 #1
0
        private Boolean CheckStatutProductAttribute(uint idproductattribute, sbyte active, out string combination)
        {
            Boolean insert_log = false;

            combination = string.Empty;
            Model.Prestashop.PsProductAttributeRepository          PsProductAttributeRepository          = new Model.Prestashop.PsProductAttributeRepository();
            Model.Prestashop.PsAECAttributeListAttributeRepository PsAECAttributeListAttributeRepository = new Model.Prestashop.PsAECAttributeListAttributeRepository();
            if (PsProductAttributeRepository.ExistProductAttribute(idproductattribute))
            {
                Model.Prestashop.PsProductAttribute PsProductAttribute = PsProductAttributeRepository.ReadProductAttribute(idproductattribute);
                if (!PsAECAttributeListAttributeRepository.ExistProductAttribute(idproductattribute))
                {
                    PsAECAttributeListAttributeRepository.Add(new Model.Prestashop.PsAEcAttributeListAttribute()
                    {
                        IDProduct          = PsProductAttribute.IDProduct,
                        IDProductAttribute = PsProductAttribute.IDProductAttribute,
                        Packing            = 1, // valeur par défaut
                        Active             = active,
                    });
                    insert_log = true;
                }
                else
                {
                    Model.Prestashop.PsAEcAttributeListAttribute PsAEcAttributeListAttribute = PsAECAttributeListAttributeRepository.ReadProductAttribute(PsProductAttribute.IDProductAttribute);
                    if (active != PsAEcAttributeListAttribute.Active)
                    {
                        PsAEcAttributeListAttribute.Active = active;
                        PsAECAttributeListAttributeRepository.Save();
                        insert_log = true;
                    }
                }
                combination = PsProductAttribute.Combination;
            }
            return(insert_log);
        }
コード例 #2
0
        public void Add(PsProductAttribute Obj, UInt32 IDShop)
        {
            this.DBPrestashop.PsProductAttribute.InsertOnSubmit(Obj);
            this.Save();

            //Si le productattribute n'existe pas dans la boutique, il est rajouté.
            if (!ExistInShop(Obj.IDProductAttribute, IDShop))
            {
                DBPrestashop.PsProductAttributeShop.InsertOnSubmit(new PsProductAttributeShop()
                {
                    AvailableDate      = Obj.AvailableDate,
                    DefaultOn          = Obj.DefaultOn,
                    EcOtAx             = Obj.EcOtAx,
                    IDProductAttribute = Obj.IDProductAttribute,
                    IDShop             = IDShop,
                    MinimalQuantity    = Obj.MinimalQuantity,
                    Price           = Obj.Price,
                    UnitPriceImpact = Obj.UnitPriceImpact,
                    Weight          = Obj.Weight,
                    WholesalePrice  = Obj.WholesalePrice,
                                        #if (PRESTASHOP_VERSION_161 || PRESTASHOP_VERSION_172)
                    IDProduct = Obj.IDProduct,
                                        #endif
                });
                DBPrestashop.SubmitChanges();
                new PsProductAttributeShopRepository().WriteDate(Obj.IDProductAttribute);
            }
        }
コード例 #3
0
 public void Delete(PsProductAttribute Obj)
 {
     this.DBPrestashop.PsProductAttributeCombination.DeleteAllOnSubmit(this.DBPrestashop.PsProductAttributeCombination.Where(o => o.IDProductAttribute == Obj.IDProductAttribute));
     this.DBPrestashop.PsProductAttributeImage.DeleteAllOnSubmit(this.DBPrestashop.PsProductAttributeImage.Where(o => o.IDProductAttribute == Obj.IDProductAttribute));
     this.DBPrestashop.PsProductAttributeShop.DeleteAllOnSubmit(this.DBPrestashop.PsProductAttributeShop.Where(o => o.IDProductAttribute == Obj.IDProductAttribute));
     this.DBPrestashop.PsStockAvailable.DeleteAllOnSubmit(this.DBPrestashop.PsStockAvailable.Where(o => o.IDProductAttribute == Obj.IDProductAttribute));
     this.DBPrestashop.PsSpecificPrice.DeleteAllOnSubmit(this.DBPrestashop.PsSpecificPrice.Where(o => o.IDProductAttribute == Obj.IDProductAttribute));
     this.DBPrestashop.PsProductAttribute.DeleteOnSubmit(Obj);
     this.Save();
 }