PrestaSharp icon indicating copy to clipboard operation
PrestaSharp copied to clipboard

Get Product Final price with filter question

Open sanctusmob opened this issue 6 years ago • 2 comments

If i wanna get the final price (tax and discounts included) i run from cli this curl --globoff "https://[email protected]/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

sanctusmob avatar Jan 13 '20 14:01 sanctusmob

Did you find any solution? I have the same problem

ITelligent-JoseAntonio avatar Nov 26 '20 12:11 ITelligent-JoseAntonio

I write my own function for this.

sanctusmob avatar Nov 27 '20 05:11 sanctusmob