[Skip to main content](#vessel-content)

#   Fonction save product

##

- **[Minie](/forum/user/43321-minie "View Minie's Profile")**
- [![Minie's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar43321.jpg)](/forum/user/43321-minie "View Minie's Profile") Topic Author
- [ Offline](/forum/user/43321-minie)

Less More

- Posts: 511
- Thank you received: 37
-
-
-

4 years 2 months ago -  4 years 2 months ago [\#344989](#344989) by [Minie](/forum/user/43321-minie "View Minie's Profile")  *[Fonction save product](/forum/5-support-en-francais-french-support-/905055-fonction-save-product#344989 "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&#95;id DESC LIMIT 1)' at line 1  Voici le bout de code :  Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save  Merci d'avance")* was created by *[Minie](/forum/user/43321-minie "View Minie's Profile")*

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 : 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-&gt;setQuery('SELECT product_id FROM #__hikashop_product WHERE product_code = "'.trim($item['superproduct'].'"')); $parent_id = $db-&gt;loadResult(); if(!empty($parent_id)){ $product-&gt;product_parent_id = $parent_id; } else{ $product-&gt;product_parent_id = 0; } $product-&gt;product_name = trim($item['name_fr']); if(empty($item['stocklevel']) OR $item['stocklevel'] == '-1'){ $product-&gt;product_quantity = 0; } else{ $product-&gt;product_quantity = $item['stocklevel']; } $product-&gt;product_code = $product_code; $product-&gt;product_published = intval($item['isavailable']); if(trim($item['taxclass']) == 'none'){ $product-&gt;product_tax_id = 21; } elseif(trim($item['taxclass']) == 'normal'){ $product-&gt;product_tax_id = 19; } elseif(trim($item['taxclass']) == 'reduced'){ $product-&gt;product_tax_id = 20; } elseif(trim($item['taxclass']) == 'reduced2'){ $product-&gt;product_tax_id = 22; } elseif(trim($item['taxclass']) == 'superreduced'){ $product-&gt;product_tax_id = 23; } if($product-&gt;product_parent_id == 0){ $product-&gt;product_type = 'main'; } else{ $product-&gt;product_type = 'variant'; } $product-&gt;product_vendor_id = 1; $product-&gt;product_keywords = trim($item['keywords_fr']); $product-&gt;product_weight = intval($item['weight']); $product-&gt;product_weight_unit = 'g'; $product-&gt;product_dimension_unit = 'mm'; $product-&gt;product_width = intval($item['width']); $product-&gt;product_length = intval($item['length']); $product-&gt;product_height = intval($item['height']); $product-&gt;product_max_per_order = 0; $product-&gt;product_access = 'all'; $product-&gt;product_group_after_purchase = ''; $product-&gt;product_min_per_order = intval($item['minorder']); $product-&gt;product_page_title = $product-&gt;product_name; $product-&gt;product_alias = JFilterOutput::stringURLSafe($product-&gt;product_name).'-'.$product_code; $product-&gt;product_description = $item['text_fr']; $product-&gt;product_meta_description = $item['text_fr']; $price = new stdClass(); if(!empty($item['manufacturerprices_eur_net'])){ $price-&gt;price_value = str_replace(',', '.', $item['manufacturerprices_eur_net']); } else{ $price-&gt;price_value = str_replace(',', '.', $item['listprices_eur_net']); } $price-&gt;price_currency_id = 1; $price-&gt;price_min_quantity = 0; $product-&gt;prices = array($price); $product-&gt;categories = array(2); $product_id = $productClass-&gt;save($product);

Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save

Merci d'avance

Last edit: 4 years 2 months ago by [Minie](/forum/user/43321-minie "View Minie's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDU1LWZvbmN0aW9uLXNhdmUtcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14323
-
-

4 years 2 months ago [\#344994](#344994) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Fonction save product](/forum/5-support-en-francais-french-support-/905055-fonction-save-product#344994 "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&#95;id DESC LIMIT 1)' at line 1  Voici le bout de code :  Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save  Merci d'avance")*

Bonjour,

Difficile de dire quoi que ce soit avec juste cette mini erreur. En plus la fonction save appelle d'autres fonction, déclenche des évènements pour les plugins, qui à leur tour peuvent faire des requêtes MySQL ou appeler d'autres fonctions, etc.
Activez l'option "debug" de la configuration Joomla et refaites la procédure. Vous devriez avoir un message d'erreur avec le callstack et notamment le fichier et la ligne d'où la requête avec le souci est exécutée.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDU1LWZvbmN0aW9uLXNhdmUtcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Minie](/forum/user/43321-minie "View Minie's Profile")**
- [![Minie's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar43321.jpg)](/forum/user/43321-minie "View Minie's Profile") Topic Author
- [ Offline](/forum/user/43321-minie)

Less More

- Posts: 511
- Thank you received: 37
-
-
-

4 years 1 month ago -  4 years 1 month ago [\#345131](#345131) by [Minie](/forum/user/43321-minie "View Minie's Profile")  Replied by *[Minie](/forum/user/43321-minie "View Minie's Profile")* on topic *[Fonction save product](/forum/5-support-en-francais-french-support-/905055-fonction-save-product#345131 "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&#95;id DESC LIMIT 1)' at line 1  Voici le bout de code :  Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save  Merci d'avance")*

Bonjour,

j'etais pourtant en mode debug au moment de lancer mon script, je n'ai aucune info de plus. ![:(](/media/kunena/emoticons/22.png ":(")

Je tiens à préciser que la ligne produit est quand même créée dans la table product (si ca peut donner un indice sur l'endroit de l'erreur)

EDIT :
J'ai désactivé le fichier error de mon template j'ai maintenant le classique carré rouge avec toutes les infos :
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
/libraries/joomla/database/driver/mysqli.php:668

Call stack
\# Function Location
1 () JROOT/libraries/joomla/database/driver/mysqli.php:668
2 JDatabaseDriverMysqli-&gt;execute() JROOT/plugins/system/falangdriver/falang_database.php:105
3 JFalangDatabase-&gt;execute() JROOT/libraries/joomla/database/driver.php:1701
4 JDatabaseDriver-&gt;loadObjectList() JROOT/plugins/system/falangdriver/falang_database.php:282
5 JFalangDatabase-&gt;loadObjectList() JROOT/plugins/system/falangdriver/falang_database.php:416
6 JFalangDatabase-&gt;loadObject() JROOT/plugins/system/falangdriver/falang_database.php:351
7 JFalangDatabase-&gt;_loadObject() JROOT/plugins/system/falangdriver/falang_database.php:143
8 JFalangDatabase-&gt;loadResult() JROOT/plugins/system/product_layout/product_layout.php:176
9 plgSystemProduct_layout-&gt;setLayoutProduct() JROOT/plugins/system/product_layout/product_layout.php:290
10 plgSystemProduct_layout-&gt;onAfterProductCreate() JROOT/libraries/joomla/event/event.php:70
11 JEvent-&gt;update() JROOT/libraries/joomla/event/dispatcher.php:160
12 JEventDispatcher-&gt;trigger() JROOT/libraries/src/Application/BaseApplication.php:108
13 Joomla\CMS\Application\BaseApplication-&gt;triggerEvent() JROOT/administrator/components/com_hikashop/classes/product.php:2792
14 hikashopProductClass-&gt;save() JROOT/components/com_gixmassaction/views/products/view.html.php:265
15 GixmassactionViewProducts-&gt;display() JROOT/libraries/src/MVC/Controller/BaseController.php:664
16 Joomla\CMS\MVC\Controller\BaseController-&gt;display() JROOT/libraries/src/MVC/Controller/BaseController.php:702
17 Joomla\CMS\MVC\Controller\BaseController-&gt;execute() JROOT/components/com_gixmassaction/gixmassaction.php:15
18 require_once() JROOT/libraries/src/Component/ComponentHelper.php:402
19 Joomla\CMS\Component\ComponentHelper::executeComponent() JROOT/libraries/src/Component/ComponentHelper.php:377
20 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:194
21 Joomla\CMS\Application\SiteApplication-&gt;dispatch() JROOT/libraries/src/Application/SiteApplication.php:233
22 Joomla\CMS\Application\SiteApplication-&gt;doExecute() JROOT/libraries/src/Application/CMSApplication.php:225
23 Joomla\CMS\Application\CMSApplication-&gt;execute() JROOT/index.php:49

Last edit: 4 years 1 month ago by [Minie](/forum/user/43321-minie "View Minie's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDU1LWZvbmN0aW9uLXNhdmUtcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14323
-
-

4 years 1 month ago [\#345139](#345139) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Fonction save product](/forum/5-support-en-francais-french-support-/905055-fonction-save-product#345139 "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&#95;id DESC LIMIT 1)' at line 1  Voici le bout de code :  Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save  Merci d'avance")*

Bonjour,

C'est le plugin product_layout qui fait une requête MySQL de manière incorrect.
Ce plugin n'est pas un plugin que nous avons développer.
Il faudrait contacter le développeur du plugin.
Pour facilement corriger le problème en attendant, vous pouvez désactiver le plugin.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDU1LWZvbmN0aW9uLXNhdmUtcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Minie](/forum/user/43321-minie "View Minie's Profile")**
- [![Minie's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar43321.jpg)](/forum/user/43321-minie "View Minie's Profile") Topic Author
- [ Offline](/forum/user/43321-minie)

Less More

- Posts: 511
- Thank you received: 37
-
-
-

4 years 1 month ago [\#345142](#345142) by [Minie](/forum/user/43321-minie "View Minie's Profile")  Replied by *[Minie](/forum/user/43321-minie "View Minie's Profile")* on topic *[Fonction save product](/forum/5-support-en-francais-french-support-/905055-fonction-save-product#345142 "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&#95;id DESC LIMIT 1)' at line 1  Voici le bout de code :  Je ne comprends pas pourquoi, il n'est même pas question des catégories dans la fonction save  Merci d'avance")*

J'essaye d'avancer, l'erreur ne se produit pas si je suspend le déclenchement du triggerEvent onAfterProductCreate ligne 2792 de la class product

Je vais donc chercher parmi les multiples plugins que j'ai créé pour ce site interminable, ca vient surement de là, ne vous embêtez pas plus, désolée pour le dérangement.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDU1LWZvbmN0aW9uLXNhdmUtcHJvZHVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.063 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
