How do I find mininimum value of multiple XML nodes & create an output in WP-ALL-IMPORT?

I am having trouble trying to get the lowest value of multiple xml nodes from an external XML feed. The feed is this XML feed: http://genusvs.co.uk/xml2015.xml

As you can see, all the xml values node are all called something different. there are 8832 cars in the feed. This is an example of one.

Read More

<vehicle>
<capid>32076</capid>
<vehicleref>1100128291</vehicleref>
<type>Car</type>
<manufacturer>VAUXHALL</manufacturer>
<model>ZAFIRA ESTATE</model>
<shortmodtext>ZAFIRA</shortmodtext>
<derivative>1.8i Design 5dr</derivative>
<additionalfreetext/>
<paint>Metallic</paint>
<created>22/05/2015 00:20:00</created>
<updated>22/05/2015 00:20:00</updated>
<notes/>
<discount>GENUS TERMS</discount>
<dealercontribution>GENUS TERMS</dealercontribution>
<deliverycharge/>
<registeredstatus/>
<registrationdate/>
<mustbeorderedby/>
<mustbedeliveredby/>
<commission>300</commission>
<source>ARVAL</source>
<vrb/>
<approxleadtime/>
<doors>5</doors>
<transmission>1</transmission>
<fueltype>1</fueltype>
<listprice/>
<Price2Year10kMaintainedCH>568.0600</Price2Year10kMaintainedCH>
<Price2Year10kNotMaintainedCH>548.8600</Price2Year10kNotMaintainedCH>
<Price2Year20kMaintainedCH>605.5000</Price2Year20kMaintainedCH>
<Price2Year20kNotMaintainedCH>569.9900</Price2Year20kNotMaintainedCH>
<Price2Year30kMaintainedCH>647.4800</Price2Year30kMaintainedCH>
<Price2Year30kNotMaintainedCH>591.5900</Price2Year30kNotMaintainedCH>
<Price3Year10kMaintainedCH>452.9400</Price3Year10kMaintainedCH>
<Price3Year10kNotMaintainedCH>427.4500</Price3Year10kNotMaintainedCH>
<Price3Year20kMaintainedCH>489.2800</Price3Year20kMaintainedCH>
<Price3Year20kNotMaintainedCH>447.2000</Price3Year20kNotMaintainedCH>
<Price3Year30kMaintainedCH>528.0100</Price3Year30kMaintainedCH>
<Price3Year30kNotMaintainedCH>465.8100</Price3Year30kNotMaintainedCH>
<Price4Year10kMaintainedCH>391.8600</Price4Year10kMaintainedCH>
<Price4Year10kNotMaintainedCH>361.2900</Price4Year10kNotMaintainedCH>
<Price4Year20kMaintainedCH>424.9000</Price4Year20kMaintainedCH>
<Price4Year20kNotMaintainedCH>378.7100</Price4Year20kNotMaintainedCH>
<Price4Year30kMaintainedCH>488.3100</Price4Year30kMaintainedCH>
<Price4Year30kNotMaintainedCH>403.4700</Price4Year30kNotMaintainedCH>
<Price2Year10kMaintainedPCH>694.7160</Price2Year10kMaintainedPCH>
<Price2Year10kNotMaintainedPCH>671.6760</Price2Year10kNotMaintainedPCH>
<Price2Year20kMaintainedPCH>739.6440</Price2Year20kMaintainedPCH>
<Price2Year20kNotMaintainedPCH>697.0320</Price2Year20kNotMaintainedPCH>
<Price2Year30kMaintainedPCH>790.0200</Price2Year30kMaintainedPCH>
<Price2Year30kNotMaintainedPCH>722.9520</Price2Year30kNotMaintainedPCH>
<Price3Year10kMaintainedPCH>557.0040</Price3Year10kMaintainedPCH>
<Price3Year10kNotMaintainedPCH>526.4160</Price3Year10kNotMaintainedPCH>
<Price3Year20kMaintainedPCH>600.6120</Price3Year20kMaintainedPCH>
<Price3Year20kNotMaintainedPCH>550.1160</Price3Year20kNotMaintainedPCH>
<Price3Year30kMaintainedPCH>647.0880</Price3Year30kMaintainedPCH>
<Price3Year30kNotMaintainedPCH>572.4480</Price3Year30kNotMaintainedPCH>
<Price4Year10kMaintainedPCH>483.9240</Price4Year10kMaintainedPCH>
<Price4Year10kNotMaintainedPCH>447.2400</Price4Year10kNotMaintainedPCH>
<Price4Year20kMaintainedPCH>523.5720</Price4Year20kMaintainedPCH>
<Price4Year20kNotMaintainedPCH>468.1440</Price4Year20kNotMaintainedPCH>
<Price4Year30kMaintainedPCH>599.6640</Price4Year30kMaintainedPCH>
<Price4Year30kNotMaintainedPCH>497.8560</Price4Year30kNotMaintainedPCH>
<ncaprating>0</ncaprating>
<co2>168</co2>
<bhp/>
<mpgcombined>39.2</mpgcombined>
<zerotosixtytwo/>
<topspeed/>
<cc/>
</vehicle>

i need to the import to read all the prices, and also create a minimum price (no inclusive of 0 or null) from all the 2, 3, 4 year – 10k, 20k, 30k – maintained and non-maintained, business or personal and import this as a custom value..

i have already managed to change them to 2 decimal places… creating a separate function for each and having a function code for each xml property in the functions.php part of WP All Import

eg .

<?php
// 10k - maintained - personal
function p2y10kmp($p2y10kmp){ $p2y10kmp = number_format($p2y10kmp, 2, '.', ''); return $p2y10kmp;}
function p3y10kmp($p3y10kmp){ $p3y10kmp = number_format($p3y10kmp, 2, '.', ''); return $p3y10kmp;}
function p4y10kmp($p4y10kmp){ $p4y10kmp = number_format($p4y10kmp, 2, '.', ''); return $p4y10kmp;}
?>

I have done this as will need all the separate values for different places on the website… the minimum value i am struggling to work out how to get, will just be as a ‘from £ +VAT’

Also all of the function values

function p4y10knmp($p4y10knmp){
$p4y10kmp = number_format($p4y10kmp, 2, '.', '');
return $p4y10kmp;
}

are imported like

[([p4y10knmch({Price4Year10kNotMaintainedCH[1]})] as required by WP ALL IMPORT

I have also tried creating an array from the added function values but i could not get anything to work with the min(array)?

example: `

$displayfrom =  min(array_diff(array_map('intval', $values), array(0))); return $displayfrom;`

If anyone can help i will happily help by giving access if needed.

The website is currently running on www.cocoonoffers.uk if you wanted to get a jist of what i am trying to do, at the moment the site is running from a local version of the xml feed, with just 21 cars in the feed. when finished, will be using the full 8832 cars

(The price value in the custom field is just a static value at the moment [p4y10knmch({Price4Year10kNotMaintainedCH[1]})]

Related posts