include '../../app/Mage.php';
include 'utilities/Category.php';
include 'utilities/Url.php';
include 'utilities/Terms.php';
Mage::app('admin');
$category_count = 200;
$default_store_id = 1;
$categoryHelper = new DLS_Utility_Helper_Category();
$termsHelper = new DLS_Utility_Helper_Terms();
$category_terms = array("Shoes", "Shirts", "Pants", "Suits", "Clothes", "Jewelry", "Stuff", "Things", "Music", "Instruments", "Sports", "Baseball", "Basketball", "Football", "Hockey", "Guitars", "Pianos", "Drums", "Bass", "Hats", "Computers", "Keyboards", "Monitors", "Sean", "Brendan");
$subterms_per_term = 3;
$number_of_terms = count($category_terms);
$created_category_paths = array();
$created_category_ids = array();
$admin_store_root_category_path = $categoryHelper->getStoreRootCategoryPath($default_store_id);
$created_category_paths[] = $admin_store_root_category_path;
$created_category_url_keys = array();
for ($c = 0; $c < $category_count; $c++) {
    $random_category_name = $termsHelper->getRandomTermFromList($category_terms, $subterms_per_term);
    $number_of_created_category_paths = count($created_category_paths);
    $random_category_path_index = rand(0, $number_of_created_category_paths - 1);
    // Should always be set, but check just in case
    $category_path = isset($created_category_paths[$random_category_path_index]) ? $created_category_paths[$random_category_path_index] : reset($number_of_created_category_paths);
    $category_data = array('name' => $random_category_name, 'description' => $random_category_name, 'meta_title' => $random_category_name, 'meta_description' => $random_category_name, 'meta_keywords' => $random_category_name, 'is_active' => 1, 'include_in_menu' => 1, 'path' => $category_path);
    $categoryObject = $categoryHelper->createCategoryObject($category_data, $default_store_id);
    $categoryObject->save();
    $created_category_ids[] = $categoryObject->getId();
    $created_category_paths[] = $categoryObject->getPath();
}
$created_category_ids_string = implode(',', $created_category_ids);
file_put_contents('./logs/created_category_ids.log', $created_category_ids_string);
$default_attribute_set_id = $eavEntityType->getDefaultAttributeSetId();
$default_store_id = 1;
$simple_product_type = 'simple';
$max_weight = 100;
$max_price = 300;
// TODO Do this a better way
$category_ids_array = array();
for ($cat_count = 3; $cat_count <= $number_of_categories_created; $cat_count++) {
    $category_ids_array[] = $cat_count;
}
$number_of_categories = count($category_ids_array);
$simple_product_data_array = array('attribute_set_id' => $default_attribute_set_id, 'type_id' => $simple_product_type, 'website_ids' => array($default_store_id), 'news_from_date' => '', 'news_to_date' => '', 'status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED, 'visibility' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, 'country_of_manufacture' => '', 'special_price' => '', 'special_from_date' => '', 'msrp_enabled' => '2', 'msrp_display_actual_price_type' => '4', 'msrp' => '', 'enable_googlecheckout' => '1', 'tax_class_id' => '0', 'image' => 'no_selection', 'small_image' => 'no_selection', 'thumbnail' => 'no_selection', 'media_gallery' => array('images' => '[]', 'values' => '{"image":null,"small_image":null,"thumbnail":null}'), 'is_recurring' => '0', 'recurring_profile' => '', 'custom_design' => '', 'custom_design_from' => '', 'custom_design_to' => '', 'custom_layout_update' => '', 'page_layout' => '', 'options_container' => 'container2', 'use_config_gift_message_available' => '1', 'can_save_configurable_attributes' => false, 'can_save_custom_options' => false, 'can_save_bundle_selections' => false);
for ($p = 0; $p < $number_of_products_to_create; $p++) {
    $specific_product_data_to_add = $simple_product_data_array;
    // Generate random product name
    $name_adjective = $termsHelper->getRandomTermFromList($product_term_adjectives, 1);
    $name_noun = $termsHelper->getRandomTermFromList($product_term_nouns, 1);
    $name = $name_adjective . ' ' . $name_noun;
    $specific_product_data_to_add['name'] = $name;
    $specific_product_data_to_add['description'] = $name;
    $specific_product_data_to_add['short_description'] = $name;
    $specific_product_data_to_add['meta_title'] = $name;
    $specific_product_data_to_add['meta_keyword'] = $name;
    $specific_product_data_to_add['meta_description'] = $name;
    $product_sku = str_replace(' ', '-', $name);
    $permuted_product_sku = $permuteHelper->getPermutedValue($product_sku, 'sku');
    $specific_product_data_to_add['sku'] = $permuted_product_sku;
    $specific_product_data_to_add['url_key'] = $permuted_product_sku;
    $random_weight = rand(1, $max_weight);
    $specific_product_data_to_add['weight'] = $random_weight;
    $specific_product_data_to_add['price'] = rand(1, $max_price);