input; $watchPrice = $jInput->get( 'watchprice' ); $watchId = $jInput->get( 'watchid' ); $watchName = $jInput->get( 'watchname' ); $watchHash = $jInput->get( 'watchhash' ); $hashkey = $watchId . $watchPrice . '1.21!stbcssblck'; $productClass = hikashop_get('class.product'); $product = new stdClass(); $product->product_name = $watchName; $product->product_code = $watchId; $product->product_msrp = $watchPrice; $product->product_published = 1; $product->product_quantity = 3; $product->product_tax_id = 11; $product->product_warehouse_id = 1; $product->categories = array(47); $price = null; $price->price_value = $watchPrice; $price->price_currency_id = 151; //151:chf 1:euro 2:usd $price->price_min_quantity = 1; $price->price_with_tax = $watchPrice; $product->prices = array($price); $result = $productClass->save($product); $productClass->updatePrices($product, $result); $productClass->updateCategories($product, $result); //$categoryClass = hikashop_get('class.category'); //$category_product = new stdClass(); //$category_product->category_id = 47; //$category_product->product_id = $productClass->product_id; //$category_product->product_id = 2867; //$result1 = $categoryClass->save($category_product); //$db =& JFactory::getDBO(); //$db->setQuery('INSERT INTO '.hikashop::table('product_category').' (product_id, category_id) VALUES ('.$productClass->product_id) .','47')'; //$current_result = $db->loadResult(); $cartClass = hikashop_get('class.cart'); $cartClass->update($result,1); $urlwatch = 'http://121configurator.121time.com/121time/orders/'. $watchId .".png"; //$urlwatch = 'https://www.121time.com/images/com_hikashop/upload/thumbnails/50x50f/customwatchhtml/2343.png'; $imgwatch = '/home/clients/d53d54a5c29e90b4075f63181c97aaa5/web/images/com_hikashop/upload/customwatchhtml/'. $watchId .".png"; $verbose = '/home/clients/d53d54a5c29e90b4075f63181c97aaa5/web/images/com_hikashop/upload/customwatchhtml/'. $watchId .".log"; /*$ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $urlwatch); $data = curl_exec($ch); curl_close($ch); print_r($urlwatch); print_r($data);*/ $ch = curl_init($urlwatch); $fp = fopen($imgwatch, 'wb'); //curl_setopt($ch, CURLOPT_VERBOSE, true); //$verbose = fopen($verbose, 'w+'); //curl_setopt($ch, CURLOPT_STDERR, $verbose); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $imageURL = 'customwatchhtml/'. $watchId .".png"; $msg = ''; //traitement image $image = new stdClass(); $image->file_ref_id = $result; $image->file_type = 'product'; $image->file_path = $imageURL; $fileClass = hikashop_get('class.file'); $id = $fileClass->save($image); $product->images = array($id); $productClass->updateFiles($product,$result,'images'); $link = '/cart/checkout'; $app = JFactory::getApplication(); $app->redirect($link, $msg); return "->price:". $watchPrice ."-id:". $watchId ."-name:". $watchName; } }