Jump to content

[Resolved] Web-service can't generate CDATA for price zero


Recommended Posts

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

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

  • 9 months later...
×
×
  • Create New...