<?php 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(); }
<?php include '../../app/Mage.php'; Mage::app('admin'); // This script is currently only written to create simple products $number_of_categories_created = 202; $number_of_products_to_create = 100; $max_categories_per_product = 6; include 'utilities/Terms.php'; include 'utilities/Url.php'; include 'utilities/Permute.php'; include 'utilities/Product.php'; $termsHelper = new DLS_Utility_Helper_Terms(); $permuteHelper = new DLS_Utility_Helper_Permute(); $product_term_adjectives = array("Green", "Blue", "Red", "Black", "White", "American", "Euro", "Asian", "Brown", "Musical", "Bright", "Dark", "Comical", "Business", "Casual", "Plain"); $product_term_nouns = array("Loafer", "Sneaker", "Boot", "Sandal", "Flip-flop", "Polo", "Button-Up", "T-Shirt", "Tank-top", "Dress", "Khakis", "Capris", "Jeans", "Sweatpants", "Necklace", "Ring", "Bracelet", "Earrings", "Song", "Album", "String", "Horn", "Trumpet", "Guitar", "Piano", "Bat", "Glove", "Spike", "Stick", "Bag", "Mouse", "USB", "HD", "HDMI", "LCD", "LED", "Plasma", "Television", "Radio", "Movie", "DVD", "CD", "MP3", "Laptop", "Desktop", "Lamp", "Brick", "Anchor", "Mens", "Womens", "Child", "Toddler", "Baby"); $productHelper = new DLS_Utility_Helper_Product(); $eavEntityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product'); $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++) {