- Posts: 252
- Thank you received: 1
How to create a product category into hikashop programmatically
8 years 3 months ago #294016
by twscott
-- HikaShop version -- : 3.4.0
Hi,
I am asking to create product category by program, Is there document for it ?
Thanks
Hi,
I am asking to create product category by program, Is there document for it ?
Thanks
Please Log in or Create an account to join the conversation.
8 years 3 months ago #294017
by nicolas
Replied by nicolas on topic How to create a product category into hikashop programmatically
Hi,
No, there is no documentation but it's quite easy:
where XX is the id of the parent category.
Note that if you want to add an image you need also something like that:
where YY is the relative path of the image from the upload folder (setting of the HikaShop configuration).
No, there is no documentation but it's quite easy:
Code:
$category = new stdClass();
$category->category_name = "My new category";
$category->category_parent_id = XX;
$categoryClass = hikashop_get('class.category');
$category_id = $categoryClass->save($category);
Note that if you want to add an image you need also something like that:
Code:
$file = new stdClass();
$file->file_ref_id = $category_id;
$file->file_ref_type = 'category';
$file->file_path = 'YY'
$fileClass = hikashop_get('class.file');
$fileClass->save($file);
Please Log in or Create an account to join the conversation.
Time to create page: 0.171 seconds