We are currently on vacation until 21st July 2025, ticket responses maybe be longer than normal during this period, sorry for any inconvenience.

import ACF Post Object Field

Closed

Import WP Addon - Advanced Custom Fields Updated 8 months ago 15 Replies

LATWAN asked 8 months ago on November 23, 2024 at 6:33 am

Hi, 

How do I go about importing post into ACF Post Object field?  I wasn\’t able to find information about how to use a custom method.  Attached is the importer json file and an example of my .cvs file.  I use column A (catalog) as the identifier but can also use post_title.

Thanks,

J

James replied Support Agent

8 months ago on November 25, 2024 at 8:34 pm

Hi Latwan,

In your csv file, the acf.related_products field value of RK-APRO? does a product exist on the website you are importing to with this value? or just on the export site?

James 

LM

LATWAN replied

8 months ago on November 27, 2024 at 8:01 am

Yes, the products already exist.

J

James replied Support Agent

8 months ago on November 27, 2024 at 8:16 am

is it the product sku, post name, or title?

LM

LATWAN replied

8 months ago on November 27, 2024 at 8:18 am

It is a custom post type named products.  I selected and acf field named catalog as the identifier on the import options. 

J

James replied Support Agent

8 months ago on November 27, 2024 at 10:05 pm

When importing to an acf relationship field you would take the chosen selector e.g.

{2}

And use a custom method to return the ID (replacing custom_field_name with the custom field you want to search for,  to find an existing post on the "product" post type using the custom field "custom_field_name" and match this against the value of {2} csv selector.

[iwp_fn_get_posts_by("{2}","custom_field_name", "product")]
LM

LATWAN replied

8 months ago on December 1, 2024 at 5:34 am

Okay, thanks.  I'll this and let you know how it goes.

LM

LATWAN replied

8 months ago on December 6, 2024 at 5:08 am

I haven't been able to get this to work.  Since I am using ACF field "catalog" as the identifier.  Do I change "custom_field_name" to "catalog" like so?

[iwp_fn_get_posts_by("{2}","catalog", "product")]

The Post Object Field "related_products" remains empty after running the import.

J

James replied privately Support Agent

8 months ago on December 9, 2024 at 10:23 pm

LM

LATWAN replied

8 months ago on December 10, 2024 at 12:43 am

There are some instances where there will be more than one related product.  Therefore, I am attaching a new .csv file as an example.

{0} main product catalog number = CEK-001-21

{1} main product name = ACTH (Rat, Mouse) - Chemiluminescent EIA Kit

{2} Related Product 1 catalog number = VT-6450 (Lavender Vacutainer Tubes)

{3} Related Product 2 catalog number = EK-BUF (Assay Buffer (20x Concentrate) for EIA/ELISA)

{4} Related Product 3 catalog number = RK-APRO (Aprotinin, 30 Trypsin Inhibitory Units (TIU))

Let me know if I should combine related products into a single column with a specific separator.  I can do that as well.  I'm just transposing a list from another database.

LM

LATWAN replied privately

8 months ago on December 10, 2024 at 12:45 am

J

James replied Support Agent

8 months ago on December 11, 2024 at 9:33 pm

Thank you for providing temporary access, from this i noticed that the post type is "products" not "product", so using this in the custom field:

[iwp_fn_get_posts_by("{2}","catalog", "products")]

Updates the preview which shows as "6798".

I will get back to you on saving of multiple relationship field values shortly.

James

 

J

James replied privately Support Agent

8 months ago on December 11, 2024 at 9:49 pm

LM

LATWAN replied privately

8 months ago on December 12, 2024 at 5:05 am

J

James replied Support Agent

8 months ago on December 12, 2024 at 11:46 am

After looking at your site, i previously presumed you were using a relationshipg field as you were wanting to import multiple (as i did not know a post object field that you are using supports multiple selection).

I have updated your plugin to allow this for post_object fields and the edit screen is showing the correct 2products

LM

LATWAN replied

8 months ago on December 16, 2024 at 6:48 pm

The update worked, thanks!