We are currently on vacation until 13th May 2024, ticket responses maybe be longer than normal during this period, sorry for any inconvenience.

Custom field Finder for Taxonomies

Closed

Import WP Pro Updated 1 month ago 16 Replies

Jens asked 1 month ago on March 23, 2024 at 12:04 pm

Hi James, its possible to add the custom field Finder to Taxonomies

For example Stores or Categories had Thumbnails.

J

James replied Support Agent

1 month ago on March 24, 2024 at 10:26 pm

Hi,

I can confirm that the custom field finder works on taxonomies, if it is not working for you this suggests that the taxonomy term custom fields are not stored in the termmeta table.

James

JG

Jens replied privately

1 month ago on March 25, 2024 at 3:38 pm

J

James replied Support Agent

1 month ago on March 25, 2024 at 6:39 pm

To find out where the data is stored, can you provide a zip file of what adds the store affiliate url, logo and other sections.

JG

Jens replied privately

1 month ago on March 25, 2024 at 6:48 pm

J

James replied Support Agent

1 month ago on March 25, 2024 at 6:49 pm

If you dont know where the data is stored, i will need you to send wordpress plugin or theme that adds those fields.

JG

Jens replied

1 month ago on March 25, 2024 at 7:49 pm

Ok, i doenst Know where its stored. So please, what you need, how i can Help?

J

James replied Support Agent

1 month ago on March 25, 2024 at 8:29 pm

Attach a zip of the plugin or theme that adds these fields.

JG

Jens replied privately

1 month ago on March 25, 2024 at 8:33 pm

JG

Jens replied privately

1 month ago on March 25, 2024 at 8:43 pm

J

James replied Support Agent

1 month ago on March 26, 2024 at 10:54 pm

Hi Jen,

I was unable to setup the theme locally to test but i could see the code and i think i understand where the data is stored.

The coupon stores data is saved in the options table instead of the termmeta table.

For reference all fields in csv:

Label, "setting key", Value
"Sidebar Description","category_sidebar_description_#ID#", text
"Footer Description","category_description_#ID#", text
"Logo (220x220px)","storeimage_#ID#", "url"
"Store Link","storelink_#ID#", text
"Store Affiliate Link","storelinkaff_#ID#", text
"Store Address","storeaddress_#ID#", text
"Store Facebook","storefb_#ID#", text
"Store Phone Number","storephone_#ID#"
"Store Email","storeemail_#ID#", text
"Image (800x600px)", "category_image_#ID#", "url"
"Text Icon", "category_icon_small_#ID#", "url"

To allow the importer to save data into the settings table you need to add the following code to your website:

add_action('iwp/register_events', function ($event_handler) {

    /**
     * @var \ImportWP\EventHandler $event_handler
     */
    $event_handler->listen('importer.custom_fields.process_field', function ($output, $post_id, $key, $value, $custom_field_record, $prefix, $importer_model, $custom_field) {

        // options::text::core_admin_values::category_sidebar_description_#ID#
        // options::attachment::core_admin_values::storeimage_#ID#
        if (strpos($key, 'options::') !== 0) {
            return;
        }

        // "core_admin_values::category_sidebar_description_#ID#"
        $k = substr($key, strlen('options::'));
        $k = str_replace('#ID#', $post_id, $k);

        // [core_admin_values, category_sidebar_description_#ID#]
        $parts = explode('::', $k);
        if (count($parts) !== 3 || !in_array($parts[0], ['text', 'attachment']) || empty($parts[1] || empty($parts[2]))) {
            return;
        }
        $field_type = $parts[0];
        $option_key = $parts[1];
        $setting_key = $parts[2];

        switch ($field_type) {
            case 'attachment':
                $value = $custom_field->processAttachmentField($value, $post_id, $custom_field_record, $prefix);
                $value = stripslashes($value);
                break;
            default:
                $value = strip_tags($value);
                break;
        }


        $existing_values = get_option($option_key, []);
        $new_result = array_merge((array)$existing_values, [$setting_key => $value]);
        update_option($option_key, $new_result, true);
    });
});

 

This will now allow you to update these fields via teh custom fields section using a specific format

options::{field_type}::{settings_key}::{field_key}

field_type = text or attachment
settings_key = core_admin_values (this is the options name in the database)
field_key = this is the custom field name you are setting from the previously mentioned list of fields.

For example setting the "Sidebar description", you would enter the custom field name as:

options::text::core_admin_values::category_sidebar_description_#ID#

And a second example for importing the "Logo (220x220px)", from the show settings panel set the attachment return type to "Attachment URL - Single Record":

options::attachment::core_admin_values::storeimage_#ID#

JG

Jens replied privately

1 month ago on March 27, 2024 at 9:04 am

J

James replied Support Agent

1 month ago on March 27, 2024 at 9:33 am

Hi Jen your importer is not importing (store taxonomy): https://dev.preml.de/wp-admin/edit-tags.php?taxonomy=store&post_type=listing_type , it is instead importing (listings post type): https://dev.preml.de/wp-admin/admin.php?page=listings

You should create a term importer for the taxonomy "store".

JG

Jens replied

1 month ago on March 27, 2024 at 12:55 pm

You See there is an taxonomy Store field. For this i gave you Access to Look and Test :)

J

James replied Support Agent

1 month ago on March 27, 2024 at 1:06 pm

The screenshot you showed does show the stores taxonomy,but to import custom fields onto terms on that taxonomy you need to use the term import template, not the post type import template. that wah the custom field import function i setup should work.

JG

Jens replied privately

1 month ago on March 27, 2024 at 1:21 pm

J

James replied Support Agent

1 month ago on March 30, 2024 at 12:12 pm

Thank you for letting me know, glad to hear it is working