Skip to content

Instantly share code, notes, and snippets.

@isratmir
Last active August 18, 2016 13:16
Show Gist options
  • Save isratmir/b94ee3d32a608f13716346f0c28187be to your computer and use it in GitHub Desktop.
Save isratmir/b94ee3d32a608f13716346f0c28187be to your computer and use it in GitHub Desktop.
<?php
private function getListing()
{
/*
$listingSid = \App()->Request['sid'];
$listing = \App()->ListingManager->getListingBySID($listingSid);
$json = $listing->getValueForEncodingToJson();
$newJson = array();
foreach ( $json as $k => $j ) {
$newJson[$k] = $j['value'];
}
$l = json_encode($newJson);
echo $l;
$decoded = json_decode($l);
echo $decoded->AxleConfig;*/
$file = fopen(PATH_TO_ROOT . '/listingz.json', 'w');
$defaultListingsNumber = 1000;
$allSids = \App()->ListingManager->getAllListingSIDs();
$rounds = round(count($allSids) / $defaultListingsNumber);
for($i=0; $i < $rounds; $i++)
{
$arrayOfSids = array_slice($allSids, 0, $defaultListingsNumber);
$numberOfArrayOfSids = count($arrayOfSids);
$listings = array();
for($j=0; $j < $numberOfArrayOfSids; $j++)
{
$listing = \App()->ListingManager->getListingBySID($arrayOfSids[$j]['sid']);
if (is_object($listing)) {
$listings[] = $listing->getValueForEncodingToJson();
$listing = null;
}
}
fwrite($file, json_encode($listings));
$listings = null;
$arrayOfSids = null;
echo count($allSids);
$allSids = array_splice($allSids, $defaultListingsNumber);
}
fclose($file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment