create new product with php

  • Posts: 73
  • Thank you received: 1
11 years 5 months ago #113954

Is there a handy function which allows me to easily create a product with php?

Currently I'm inserting data inside these 3 tables:
hikashop_product
hikashop_product_category
hikashop_price

but the product won't seam to appear in hikashop.

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

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
11 years 5 months ago #113964

Yes:

$product = null;
$product->product_name = 'test';
$product->categories = array(2,6); // for the categories with the ids 2 and 6.
$price = null;
$price->price_value = 10;
$price->price_currency_id = 1;
$product->prices = array($price);

$productClass = hikashop_get('class.product');
$result = $productClass->save($product);
$productClass->updateCategories($product, $result);
$productClass->updatePrices($product, $result);

For a more complete example, you can look at the "saveForm" function of the product class which handle the saving of all the information of the product edition page.

Last edit: 11 years 5 months ago by nicolas.
The following user(s) said Thank You: Ortix

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

  • Posts: 73
  • Thank you received: 1
11 years 5 months ago #113996

you're a friggin boss!

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

Time to create page: 0.053 seconds
Powered by Kunena Forum