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

Get Product Final price with filter question #388

Open sanctusmob opened 4 years ago

sanctusmob commented 4 years ago

If i wanna get the final price (tax and discounts included) i run from cli this curl --globoff "https://APIKEY@www.example.com/api/products/60317?price[final_price][use_tax]=1"

How can i translate this to the C# using prestasharp?

I try this

Dictionary<string, string> dicFilterPrice = new Dictionary<string, string>();
dicFilterPrice.Add("id", Library.ToStringNullSafe(myProduct.ProductID));
dicFilterPrice.Add("price[final_price][use_tax]", "1");
Bukimedia.PrestaSharp.Factories.ProductFactory productFactory = new Bukimedia.PrestaSharp.Factories.ProductFactory(Library.strPSWSUrl, Library.strPSWSUsername, Library.strPSWSPassword);
List<Bukimedia.PrestaSharp.Entities.product> psProducts = new List<Bukimedia.PrestaSharp.Entities.product>();
try
{
    psProducts = productFactory.GetByFilter(dicFilterPrice, "id_DESC", "1");
}
catch(Exception ex)
{
    Library.WriteErrorLog("Exception: " + ex.Message);
}

but it throws exception

display: full
filter[id]: 85
filter[price[final_price][use_tax]]: 1
sort: id_DESC
limit: 1
date: 1
ws_key: 

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[31]]></code>
<message><![CDATA[There is no existing linked table for this resource]]></message>
</error>
</errors>
</prestashop>
 Object reference not set to an instance of an object. HttpStatusCode: BadRequest
ITelligent-JoseAntonio commented 4 years ago

Did you find any solution? I have the same problem

sanctusmob commented 4 years ago

I write my own function for this.