SaintAndrews Posted October 24, 2014 Share Posted October 24, 2014 Hi everyone!! Im new doing prestashop's modules and i cant insert correctly products into prestashop. I have created a module who gets a csv from FTP and inserts his content into prestashop but it doesn't work right. Here is my code: while (($datos = fgetcsv($archivo, 0, ";")) !== FALSE){ $i++; //compruebo que no sea la primera linea del fichero if($i != 1){ $object = new AdminImportController(); $object->name = array((string)(Configuration::get('PS_LANG_DEFAULT')) => $datos[2]); $object->supplier = (string)$datos[3]; $object->description = (string)$datos[4]; $object->weight = (double)$datos[6]; $object->wholesale_price = (double)$datos[7]; $object->reference = (string)$datos[9]; $object->ean13 = (string)$datos[12]; $object->active = 1; $object->supplier_reference = (string)$datos[1]; $object->link_rewrite = array((string)(Configuration::get('PS_LANG_DEFAULT'))=> 'es'); $object->condition = 'new'; / $object->default_category = 2; o $object->id_manufacturer = 0; ar $object->price = 0; $object->id_tax_rules_group = 0; $object->id_supplier = 0; $object->minimal_quantity = 1; $object->additional_shipping_cost = 0; $object->ecotax = 0; $object->width = 0; $object->height = 0; $object->depth = 0; $object->out_of_stock = 1; $object->available_for_order = 1; $object->indexed = 1; $object->show_price = 1; $object->on_sale = 1; $object->online_only = 1; $object->save(); $object->add(); } } I can't link these product to categories and photos and i'm kind desesperated here. Any help would be very appreciated!! From now Thanks. Link to comment Share on other sites More sharing options...
nsweb Posted October 29, 2014 Share Posted October 29, 2014 must be $object = new Product(); $object->link_rewrite = Tools::link_rewrite($your_name); remove one of $object->save(); or $object->add(); they do the same you must set default category $object->id_category_default = 2; and all possible categories$object->id_category = array(2,3,4); after product is saved you must call $object->updateCategories($object->id_category); Search indexation Search::indexation(false, $object->id); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now