tuan
9/1/2015 - 2:25 AM

create category by fastimport extension #Magento #IMport #Category

create category by fastimport extension #Magento #IMport #Category

<?php

$createCategory = function() {
    $data = array();

    $arrKey = array(
        'Men',
        'Men/Shirts',
        'Men/New Arrivals',
        'Men/Tees, Knits and Polos',
        'Men/Pants & Denim',
        'Men/Blazers',

        'Women',
        'Women/New Arrivals',
        'Women/Tops & Blouses',
        'Women/Pants & Denim',
        'Women/Dresses & Skirts',
        'Women/Sub women',
        'Women/Women 2',

        'Accessories',
        'Accessories/Eyewear',
        'Accessories/Jewelry',
        'Accessories/Shoes',
        'Accessories/Bags & Luggage',

        'Home & Decor',
        'Home & Decor/Books & Music',
        'Home & Decor/Bed & Bath',
        'Home & Decor/Electronics',
        'Home & Decor/Decorative Accents',

        'Sale',
        'Sale/Women',
        'Sale/Men',
        'Sale/Accessories',
        'Sale/Home & Decor',
    );

    foreach($arrKey as $strCatHaveParent) {
        $arrCatName = explode('/', $strCatHaveParent);
        $catName = end($arrCatName);
        $data[] = array(
            '_root' => 'Default Category',
            '_category' => $strCatHaveParent,
            'description' => $catName,
            'is_active' => 'yes',
            'include_in_menu' => 'yes',
            'meta_description' => 'Meta Test',
            'available_sort_by' => 'position',
            'default_sort_by' => 'position',
        );
    }

//    $data[] = array(
//        '_store' => 'storename',
//        'name' => 'Storeview name',
//        'description' => 'Never specify a name in admin store level, the name is extracted out of the _category path'
//    );

    /** @var $import AvS_FastSimpleImport_Model_Import */
    $import = Mage::getModel('fastsimpleimport/import');
    try {
        $import->processCategoryImport($data);
    } catch (Exception $e) {
        print_r($import->getErrorMessages());
    }
};