How to insert an opencart category with SQL only.
I've always set the default store (0).
I've always set the default store (0).
SET @catname = 'MyCategory';
INSERT INTO `test`.`oc_category` (`category_id`, `image`, `parent_id`, `top`, `column`, `sort_order`, `status`, `date_added`, `date_modified`) VALUES (NULL, '', '0', '0', '1', '0', '1', '2015-09-02 00:00:00', '2015-09-02 00:00:00');
SET @lastinsert = LAST_INSERT_ID();
/*2 insert for language id 1english and id 2 italian - in my case*/
INSERT INTO `test`.`oc_category_description` (`category_id`, `language_id`, `name`, `description`, `meta_title`, `meta_description`, `meta_keyword`) VALUES (@lastinsert, '1', @catname, @catname, @catname, @catname, @catname);
INSERT INTO `test`.`oc_category_description` (`category_id`, `language_id`, `name`, `description`, `meta_title`, `meta_description`, `meta_keyword`) VALUES (@lastinsert, '2', @catname, @catname, @catname, @catname, @catname);
INSERT INTO `test`.`oc_category_to_store` (`category_id`,`store_id`) VALUES( @lastinsert, '0');
INSERT INTO `oc_url_alias` (`query`, `keyword`) VALUES (CONCAT('category_id=', @lastinsert ), @catname);
INSERT INTO `oc_category_path` (`category_id`, `path_id`, `level`) VALUES (@lastinsert, @lastinsert, '0') ;
Comments
Post a Comment