Adding product issue while using hikashop api

  • Posts: 10
  • Thank you received: 1
8 years 8 months ago #231906

-- HikaShop version -- : 2.6.1
-- Error-message(debug-mod must be tuned on) -- : 500 server error

Hi there.
I'm going to add a single product to hikashop by it's api for custom php codes. I load joomla framework and hikashop helper.php fine. I even can load a single product ang get it's fields.

Now I want to add a product, and when I write $product->save($product); it gives me 500 server error. My codes:

$product = hikashop_get('class.product');
$product->product_name = "vahid product test";
$product->product_quantity = 5;
$product->product_published = 1;
//$product->product_tax_id = 11;
$product->product_weight = 1;
$product->product_weight_unit = "kg";
//$product->product_min_per_order = $min_order;
$product->product_type = "main";
$product->product_access = "all";
/*$product->product_manufacturer_id = $id_merek;
$product->grup = $grup;
$product->tipe = $tipe;
$product->unit = $unit;*/

$product->prices = array(15000);
$product->categories = array(17);
$product->save($product);

Attachments:
Last edit: 8 years 8 months ago by vahid.vdn.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 8 months ago #231915

Your code is wrong.
It should be:

$productClass = hikashop_get('class.product');
$product = new stdClass();
$product->product_name = "vahid product test";
$product->product_quantity = 5;
$product->product_published = 1;
//$product->product_tax_id = 11;
$product->product_weight = 1;
$product->product_weight_unit = "kg";
//$product->product_min_per_order = $min_order;
$product->product_type = "main";
$product->product_access = "all";
/*$product->product_manufacturer_id = $id_merek;
$product->grup = $grup;
$product->tipe = $tipe;
$product->unit = $unit;*/
$product->prices = array(15000);
$product->categories = array(17);
$productClass->save($product);

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

Time to create page: 0.053 seconds
Powered by Kunena Forum