Skip to main content

How to create a product category into hikashop programmatically

More
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

Please Log in or Create an account to join the conversation.

More
8 years 3 months ago #294017 by nicolas
Hi,

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);
where XX is the id of the parent 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);
where YY is the relative path of the image from the upload folder (setting of the HikaShop configuration).

Please Log in or Create an account to join the conversation.

Time to create page: 0.209 seconds
Powered by Kunena Forum