Hi @reniak
How to split the result into separate fields: screenshot
My suggestion for this would be to use the pmxi_saved_post hook to programmatically add the attributes to the product, rather than using our user interface: http://www.wpallimport.com/documentation/developers/action-reference/.
If that’s not possible, you’d have to add all possible attributes to the import template and use functions in each name/value field to output the data. If you do this, I’d strongly suggest putting the results of the att_contents() call in an option (see: https://codex.ww.wp.xz.cn/Options_API) and extracting the data from that when possible (to avoid so many calls to the external URL). Be sure to clear the option as each post is saved/updated using the pmxi_saved_post hook.
Thread Starter
reniak
(@reniak)
Thanks for the reply,
the most likely is to add the properties to the user interface.
You might be a little more accurate when you say that:
“I’d strongly suggest putting the results of the att_contents() call in an option (see: https://codex.ww.wp.xz.cn/Options_API) and extracting the data from that when possible”
Thank you
Hi @reniak
You might be a little more accurate when you say that:
“I’d strongly suggest putting the results of the att_contents() call in an option (see: https://codex.ww.wp.xz.cn/Options_API) and extracting the data from that when possible”
Basically I mean that you should store the results of this call for each record:
$response = wp_remote_get( $url );
Here’s some untested example code to explain:
// See if the data has already been saved
$response = get_option( 'my_saved_response' );
if ( ! $data ) {
// If it hasn't been, go ahead and make the call
$response = wp_remote_get( $url );
// store the result in an option so you don't have to retrieve it over and over
update_option( 'my_saved_response', $response );
}
// do the rest of your operations in the function here
Then you’d use our hook to erase the saved response as each record is saved so that you can re-do the request for each product:
add_action( 'pmxi_saved_post', 'my_clear_response', 10, 1 );
function my_clear_response( $id ) {
delete_option( 'my_saved_response' );
}
Please keep in mind that this is untested and possibly broken code, it’s only meant to explain the idea.
Thread Starter
reniak
(@reniak)
Thanks again for the reply,
The code indicates it works but i have this error:
“Warning, mod_fcgid: stderr: PHP Notice: Undefined variable: data in ….wp-content/uploads/wpallimport/functions.php on line…”
Thank you
-
This reply was modified 6 years, 4 months ago by
reniak.
-
This reply was modified 6 years, 4 months ago by
reniak.
Hi @reniak
You can fix that warning by changing $data to $response.