Baby Moon Posted September 20, 2011 Share Posted September 20, 2011 Hi, I have some product items' price is zero, when use webservice get the item data, some of the price fields are empty, <price>,<unit_price>, but <wholesale_price> got value, like this, <wholesale_price><![CDATA[0.000000]]></wholesale_price>, others are like this, <price></price>. Is this a bug? or something else. Link to comment Share on other sites More sharing options...
Baby Moon Posted September 21, 2011 Author Share Posted September 21, 2011 After debugging the webservice, I found the problem. In WebServiceRequest.php, start from Line 320, got code: $return_value = Product::priceCalculation(null, $value['object_id'], $id_product_attribute, $id_country, $id_state, $id_county, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $use_ecotax, $specific_price_output, null); $arr_return[$name] = array('sqlId'=>strtolower($name), 'value'=>$return_value); The function Product::priceCalculation returns a float value, e.g. the price. After get the price, in WebserviceOutputXML.php, Line 128, got code: if ($field['value'] != '') $node_content .= '<![CDATA['.$field['value'].']]>'; It compares the float value with a empty string, when the value is 0, it will be false, so, no cdata value generated. I suggest modify Line 321 of WebServiceRequest.php as the following: $return_value = Product::priceCalculation(null, $value['object_id'], $id_product_attribute, $id_country, $id_state, $id_county, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $use_ecotax, $specific_price_output, null); $arr_return[$name] = array('sqlId'=>strtolower($name), 'value'=>sprintf('%f', $return_value)); Test successful on my server. Link to comment Share on other sites More sharing options...
Bruno Leveque Posted July 11, 2012 Share Posted July 11, 2012 Hi guys, Thank you for your report and your fix, I just fixed it on SVN: http://forge.prestashop.com/browse/PSCFI-5696 It will be available in v1.4.9 soon! Regards, Link to comment Share on other sites More sharing options...
Recommended Posts