foreach ($rules as $rule) { $length = (int) $rule->Length; // if length is 0 there is no need to add to the database if ($length > 0) { $rangeArray = explode('-', $rule->Range); $fromValue = substr($rangeArray[0], 0, 5); $toValue = substr($rangeArray[1], 0, 5); $registrantFrom = substr($rangeArray[0], 0, $length); $registrantTo = substr($rangeArray[1], 0, $length); $registrationGroup = eZISBNRegistrantRange::create($isbnGroupID, $fromValue, $toValue, $registrantFrom, $registrantTo, $length); $registrationGroup->store(); } } } // get group ranges $groupRanges = $xml->xpath('///EAN.UCC/Rules/Rule'); foreach ($groupRanges as $groupRange) { $registrationGroupItemLength = (int) $groupRange->Length; // if length is 0 there is no need to add to the database if ($registrationGroupItemLength > 0) { $rangeArray = explode('-', $groupRange->Range); $fromValue = substr($rangeArray[0], 0, 5); $toValue = substr($rangeArray[1], 0, 5); $groupFrom = substr($rangeArray[0], 0, $registrationGroupItemLength); $groupTo = substr($rangeArray[1], 0, $registrationGroupItemLength); $registrationGroupRange = eZISBNGroupRange::create($fromValue, $toValue, $groupFrom, $groupTo, $registrationGroupItemLength); $registrationGroupRange->store(); } } $cli->output('Complete'); $script->shutdown();