Last active
August 29, 2015 14:06
-
-
Save real34/7d36c50d024849c1c3a2 to your computer and use it in GitHub Desktop.
Generates a valid CSV file for french stores for the Magento Store Locator extension. http://www.magentocommerce.com/magento-connect/store-locator-extension-1.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$faker = Faker\Factory::create('fr_FR'); | |
$output = fopen('php://output', 'w+'); | |
$headers = [ | |
'storelocator_id', | |
'name', | |
'status', | |
'address', | |
'city', | |
'state', | |
'country', | |
'zipcode', | |
'latitude', | |
'longtitude', | |
'fax', | |
'phone', | |
'email', | |
'link', | |
'zoom_level', | |
'image_name', | |
'tag_store' | |
]; | |
fputcsv($output, $headers); | |
for ($i = 0; $i < 200; $i++) { | |
fputcsv($output, [ | |
$faker->unique()->randomNumber, | |
$faker->company, | |
'Enabled', | |
$faker->streetAddress, | |
$faker->city, | |
$faker->departmentName, | |
'FR', | |
$faker->postcode, | |
'', | |
'', | |
'', | |
$faker->phoneNumber, | |
$faker->companyEmail, | |
$faker->url, | |
12, | |
'', | |
'', | |
]); | |
} | |
fclose($output); |
Much better indeed! I updated the gist in case someday someone will read it :)
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should use streams instead of a table to be able to output a lot of lines without using too much memory.