How to get custom field value of single drop down

  • Posts: 56
  • Thank you received: 1
7 years 10 months ago #275241

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.3

Hi,

to set my google_product_category, for google shopping, I've add a product custom filed named google_category, single drop down type, whit numeric key and string value, when i insert a product and set google_category, in db table is saved numeric key value, but when i trie to get value, for examplre in google product plugin, i get numeric key and not string value. If i print a dump of $product in google_product_plugin i only see the key value but non the string value.

I've see the field value with key::value in hikashop_field table, but i don't know how to use it.

It's possible to get string value instead int key value ?

Many thanks

Luca

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

  • Posts: 83933
  • Thank you received: 13588
  • MODERATOR
7 years 10 months ago #275278

Hi,

It's normal that the google products plugin uses the key and not the title of the value.
You're supposed to enter the value you want in the google products xml as key and you can have what you want for the title of the value.
If you want to change that and do it differently, that would require modifying the code of the plugin in plugins/hikashop/google_products/google_products.php

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

  • Posts: 56
  • Thank you received: 1
7 years 10 months ago #275283

Hi Nicolas,

Ok, many thanks for the reply.
I take in consideratain to use the value as the key, but my value is long string like: "Cibo, bevande e tabacco > Alimenti > Condimenti e salse > Salsa di soia", because now i generate the XML file with the full category path instead the category ID (in value). Now i've 2 solutions modify the key value of the option values, and use google category ID instead an arbitrare progressive value but if i decide to follow this road, i have to change manually/with query all the google_category field values in table hikashop_products (almost 700 products).The other solution is to modify the code of the plugin to get the title instead of key value.

For the second one, how can get titel value of a custom single drop down field if i've the key value ?

Many thanks again

Luca

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

  • Posts: 83933
  • Thank you received: 13588
  • MODERATOR
7 years 10 months ago #275286

Hi,

Note that you'll have to redo the modification each time you update HikaShop.
So while in the short term it might be faster to change the code of the plugin, in the long term I don't think it will.

The line to change is :
$text = $product->$column;
in the plugin file.
You would have to use something like that:

if( $param=="category")
$text = $fieldsClass->show($fields[$column], $product->$column);
else
$text = $product->$column;

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

  • Posts: 56
  • Thank you received: 1
7 years 9 months ago #276001

Hi Nicholas,
i decided to replace the string of the category full path with the id, i think this is the best solution.

About the modification of the code of the plugin, i've add a product field named gm_export, a flag to decide if a product will be exported or not. So I've modified the source of the plugin to check this flag.

Now for doesn't loose my modification i must edit the source code of the plugin every hikashop update ?

There is a way to not lose the modification in the update process ?

Many thanks and best regards

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

  • Posts: 26251
  • Thank you received: 4040
  • MODERATOR
7 years 9 months ago #276002

Hello,

As Nicolas wrote:

Note that you'll have to redo the modification each time you update HikaShop.


Afterwards, there is still the possibility to duplicate the plugin.
If you create a new plugin with a different name and you copy the "google product" plugin code into (and perform little modifications to change the name of the plugin in the code) you will have your own custom plugin.
Thus, the google products plugin would be updated with HikaShop but it won't touch your customized plugin and you will keep your modifications.

docs.joomla.org/Creating_a_Plugin_for_Joomla

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 56
  • Thank you received: 1
7 years 9 months ago #276109

Ok, good idea

Many thanks

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

Time to create page: 0.056 seconds
Powered by Kunena Forum
loading