Bonjour,
j'utilise régulièrement la fonction save de la class product, et aujourd'hui elle me renvoie une erreur :
Error: Call to a member function get() on null: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY category_id DESC LIMIT 1)' at line 1
Voici le bout de code :
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
$productClass = hikashop_get('class.product');
$Hconfig = hikashop_config();
$product = new stdClass();
$db->setQuery('SELECT product_id FROM #__hikashop_product WHERE product_code = "'.trim($item['superproduct'].'"'));
$parent_id = $db->loadResult();
if(!empty($parent_id)){
$product->product_parent_id = $parent_id;
}
else{
$product->product_parent_id = 0;
}
$product->product_name = trim($item['name_fr']);
if(empty($item['stocklevel']) OR $item['stocklevel'] == '-1'){ $product->product_quantity = 0; }
else{ $product->product_quantity = $item['stocklevel']; }
$product->product_code = $product_code;
$product->product_published = intval($item['isavailable']);
if(trim($item['taxclass']) == 'none'){
$product->product_tax_id = 21;
}
elseif(trim($item['taxclass']) == 'normal'){
$product->product_tax_id = 19;
}
elseif(trim($item['taxclass']) == 'reduced'){
$product->product_tax_id = 20;
}
elseif(trim($item['taxclass']) == 'reduced2'){
$product->product_tax_id = 22;
}
elseif(trim($item['taxclass']) == 'superreduced'){
$product->product_tax_id = 23;
}
if($product->product_parent_id == 0){
$product->product_type = 'main';
}
else{
$product->product_type = 'variant';
}
$product->product_vendor_id = 1;
$product->product_keywords = trim($item['keywords_fr']);
$product->product_weight = intval($item['weight']);
$product->product_weight_unit = 'g';
$product->product_dimension_unit = 'mm';
$product->product_width = intval($item['width']);
$product->product_length = intval($item['length']);
$product->product_height = intval($item['height']);
$product->product_max_per_order = 0;
$product->product_access = 'all';
$product->product_group_after_purchase = '';
$product->product_min_per_order = intval($item['minorder']);
$product->product_page_title = $product->product_name;
$product->product_alias = JFilterOutput::stringURLSafe($product->product_name).'-'.$product_code;
$product->product_description = $item['text_fr'];
$product->product_meta_description = $item['text_fr'];
$price = new stdClass();
if(!empty($item['manufacturerprices_eur_net'])){
$price->price_value = str_replace(',', '.', $item['manufacturerprices_eur_net']);
}
else{
$price->price_value = str_replace(',', '.', $item['listprices_eur_net']);
}
$price->price_currency_id = 1;
$price->price_min_quantity = 0;
$product->prices = array($price);
$product->categories = array(2);
$product_id = $productClass->save($product);
Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save
Merci d'avance