Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
155 stars 151 forks source link

Update stock not working with combinations #400

Closed polaije closed 10 months ago

polaije commented 4 years ago

Hello, Here is the code used for updating combination but the update return no error but Nothing is changed in the product : CombinationFactory Combination = new CombinationFactory(Properties.Settings.Default.BaseUrl2, Properties.Settings.Default.Account2, ""); Dictionary<string, string> filterComb = new Dictionary<string, string>(); filterComb.Add("id_product", prestaProduct.id.ToString()); SelCom = Combination.GetByFilter(filterComb, null, null); StockAvailableFactory St = new StockAvailableFactory(BaseUrl2, Account2, ""); Dictionary<string, string> filterSt = new Dictionary<string, string>();

            for (int ii = 0; ii <= SelCom.Count - 1; ii++)
            {
                filterSt.Clear();
                filterSt.Add("id_product_attribute", SelCom[ii].id.ToString());
                var St1 = St.GetByFilter(filterSt, null, null);
                if (St1.Count == 1)
                {
                    SelCom[ii].quantity = St1[0].quantity;
                    combination Combinaison = SelCom[ii];
                    decimal TVA = prestaProduct.id_tax_rules_group == 17 ? 6 : 21;
                    decimal Prix = prestaProduct.price + Combinaison.price;
                    decimal PrixTVAC = (Math.Ceiling(Prix * (100 + TVA)));
                    int Stock = Combinaison.quantity;
                    if (Stock == 0)
                    {
                         //Check on website factory if stock >0                            
                        Retour = CheckFebelco(prestaProduct, "Com", Combinaison.reference, Stock);
                        if (Retour.Substring(0, 1) == "D") // stock OK
                        {
                            Combinaison.quantity = 20;
                            Combination.Update(Combinaison);
                            St.Update(St1[0]); // I am not sure if I have to do it

                        }
                    }
                }

                else
                    MessageBox.Show("Erreur recherche stock " + SelCom[ii].id.ToString());
            }

Can you help me with this issue.

Jean-Marie

github-advanced-security[bot] commented 1 year ago

You have successfully added a new CodeQL configuration /language:csharp. As part of the setup process, we have scanned this repository and found 16 existing alerts. Please check the repository Security tab to see all alerts.