Bukimedia / PrestaSharp

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

Categories Names Change on Post #413

Open Geokir77 opened 3 years ago

Geokir77 commented 3 years ago

Please consider making a Pull Request if you are capable of doing so.

*If your problem is how to implement anything with PrestaSharp or make a question, please, refer to our Slack# group with this request link:

Library Version:

1.2.9

NuGet Package Url:

https://www.nuget.org/packages/PrestaSharp/1.x.x

Prestashop version:

1.7.x

Describe the Bug:

Dear All, Firstly I should point out that I am really new to Prestashop (so excuse me if what I am saying is not completly correct)

Now I am trying to loop through a dataset of products extracted from an sql database and import them into a prestashop instance. My presta consists of only one language (greek) which is also the default one I have a simple logic where I first check if the product exists. If it doesn't I create a prestaproduct instance and insert all information I have collected from the datasets.Record. All fields on the product's basic information are inserted corectly. But my problem is with the categories list. In order for me to show the product onto the frontend, I must first combine it into a category. So while creating the related categories and subcategories (I only have two levels) Even though my string is in greek and I update all categories fields like (description, meta_description, and so on) at the final post of the category attribute Presta auto translates all fields info in English. Actually, it does something like Greeklish I should say. So for example if my Greek description is "Ηλεκτρολογικα" I get an auto-translate of "hlektrologika" and the Category is posted without the greek letters rather by the English letters.

The following code is what I use to create a category. (Take note that the laguage id inside presta is 2==Greek) ///// ***

public category CreateNewCategory(ConnectionsData ConnsDt, Product prod) { ConnectionsData ConnCheckDt = ConnsDt; ConnsDt.ConnStatus = 0; category RetVal = new category(); try { CategoryFactory CategoryFactory = new CategoryFactory(ConnsDt.BaseUrl, ConnsDt.Account, ConnsDt.PassWord); Bukimedia.PrestaSharp.Entities.AuxEntities.language CategLang = new Bukimedia.PrestaSharp.Entities.AuxEntities.language(); Bukimedia.PrestaSharp.Entities.category Category = new Bukimedia.PrestaSharp.Entities.category(); CategLang.id = 2; CategLang.Value = prod.MasterCateg; Category.active = 1; Category.id_parent = 2; Category.AddDescription(CategLang); Category.AddName(CategLang); Category.AddMetaDescription(CategLang); Category.AddMetaKeywords(CategLang); Category.AddMetaTitle(CategLang); Category.AddLinkRewrite(CategLang); RetVal = CategoryFactory.Add(Category); } catch (Exception z) { ConnCheckDt.ConnError = z.ToString(); LogMessages LogErr = new LogMessages(); LogErr.DateError = DateTime.Now; LogErr.ErrorMessage = z.ToString(); LogErr.ObjectType = "Pressta Create Master Categ"; LogErr.ObjectCode = Convert.ToString(prod.MasterCateg); LogErr.InsertLog(LogErr, ConnsDt.SqlConn); RetVal = null; return RetVal; }

        return RetVal;

} /////****

image

Expected Behavior: My guess is that the expected behavior should be that the descriptions should appear greek

Thanks In advance!!!!! George

enesbehlul commented 3 years ago

I think you should change the language from prestashop backoffice.

international>localization