Jump to content

Import Categories csv file in my own module in php not through admin panel


Recommended Posts

Hi

I'm new to prestashop 1.7 . I'm writing a module to import data (categories) from my API to a multi-store. I'm getting all the data from the API into a new csv file (The file structure respect the documentation specifications) but a don't know how I can import that file. I don't want to use the administration panel to import it, I want my module to do it. I though that I could re-use maybe one of AdminImportController's functions but I don't know if it even a solution or which one to use or how to use it.

I'll be glad if anyone can give me any clue.

 

Ps

I've already try to go through the file and import one by one. 

function createCategory($name, $id_parent, $id_shop){
	$default_lang = (int)Configuration::get('PS_LANG_DEFAULT')
    $category = new Category();

    $category->name = array($default_lang => $name);

    if($id_parent == 0){
    $category->is_root_category = 1;
    } else {
    $category->id_parent = $id_parent;
    }

    $category->id_shop_default = $id_shop;
    $category->link_rewrite = array($default_lang => "dummy_link");

    if($category->add()){
    	return $category->id;
    }
    return false;
}

 the thing it's taking so much time until a get a timeout 

I really need help. I'm not afraid to do anything from skratch. :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...