Kikert Posted July 30, 2014 Share Posted July 30, 2014 Hi', I'm creating custom products importer for Prestashop. The problem is, I have really complicated categories structure (6-level depth) and it takes a lot of time to add them (even 38 seconds for one) to the database. I've decide to create custom function to speed it up: function addCategory($name, $rewrite_name, $parent, $depth) { $d = date("Y-m-d H:i:s"); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $db->execute('INSERT INTO '._DB_PREFIX_.'category (id_parent, level_depth, active, date_add, date_upd) VALUES ('. $parent .', '. $depth .', 1, "'. $d .'", "'. $d .'")'); $id = $db->Insert_ID(); $db->execute('INSERT INTO '._DB_PREFIX_.'category_group (id_category, id_group) VALUES ('. $id .', 1), ('. $id .', 2), ('. $id .', 3)'); $db->execute('INSERT INTO '._DB_PREFIX_.'category_lang (id_category, id_lang, name, link_rewrite) VALUES ('. $id .', '. (int)Configuration::get('PS_LANG_DEFAULT') .',"'. $name .'", "'. $rewrite_name .'")'); return $id; } The problem is, after successfull executing these queries data is inserted to the tables, but not visible in front nor in backend office. Am I missing something? Maybe I calculate something wrong? Link to comment Share on other sites More sharing options...
Recommended Posts