Skip to content

Instantly share code, notes, and snippets.

@joewashere
Created December 11, 2018 22:30
Show Gist options
  • Save joewashere/ca1f0d1f6ddee73609068206124ce380 to your computer and use it in GitHub Desktop.
Save joewashere/ca1f0d1f6ddee73609068206124ce380 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . '/vendor/autoload.php';
use pdeans\Miva\Provision\Manager as Provision;
$store_code = 'PS';
$url = 'http://www.example.com/mm5/json.mvc?Function=Module&Module_Code=remoteprovisioning&Module_Function=XML';
$token = '12345';
$records = 5;
$prv = new Provision($store_code, $url, $token);
$faker = Faker\Factory::create();
$xml = '';
for($i=0; $i<$records; $i++){
$xml .= $prv->create('Order_Add', [
'@tags' => [
'ShipFirstName' => $faker->firstName,
'ShipLastName' => $faker->lastName,
'ShipEmail' => $faker->email,
'ShipPhone' => $faker->phoneNumber,
'ShipAddress1' => $faker->streetAddress,
'ShipAddress2' => $faker->buildingNumber,
'ShipCity' => $faker->city,
'ShipState' => $faker->state,
'ShipZip' => $faker->postcode,
'ShipCountry' => $faker->country,
'BillFirstName' => $faker->firstName,
'BillLastName' => $faker->lastName,
'BillEmail' => $faker->email,
'BillPhone' => $faker->phoneNumber,
'BillAddress1' => $faker->streetAddress,
'BillAddress2' => $faker->buildingNumber,
'BillCity' => $faker->city,
'BillState' => $faker->state,
'BillZip' => $faker->postcode,
'BillCountry' => $faker->country,
'Items' => [
'Item' => [
[
'Code' => $faker->ean8,
'Name' => $faker->sentence($nbWords = 3, $variableNbWords = true),
'Price' => $faker->numberBetween($min = 20, $max = 100),
'Weight' => $faker->numberBetween($min = 1, $max = 20),
'Quantity' => $faker->numberBetween($min = 1, $max = 10),
'Options' => [
'Option' => [
'AttributeCode' => 'color',
'OptionCode' => $faker->safeColorName
],
],
],
[
'Code' => $faker->ean8,
'Name' => $faker->sentence($nbWords = 3, $variableNbWords = true),
'Price' => $faker->numberBetween($min = 20, $max = 100),
'Weight' => $faker->numberBetween($min = 1, $max = 20),
'Quantity' => $faker->numberBetween($min = 1, $max = 10),
'Options' => [
'Option' => [
'AttributeCode' => 'color',
'OptionCode' => $faker->safeColorName
],
],
],
[
'Code' => $faker->ean8,
'Name' => $faker->sentence($nbWords = 3, $variableNbWords = true),
'Price' => $faker->numberBetween($min = 20, $max = 100),
'Weight' => $faker->numberBetween($min = 1, $max = 20),
'Quantity' => $faker->numberBetween($min = 1, $max = 10),
'Options' => [
'Option' => [
'AttributeCode' => 'color',
'OptionCode' => $faker->safeColorName
],
],
],
],
],
],
]);
}
file_put_contents('provide.xml', $xml);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment