Created
March 1, 2017 16:11
-
-
Save EricBusch/a2b66cb138b874a7cc291e8b5a6d1f3f to your computer and use it in GitHub Desktop.
Import a product's image during a Product Set import/update instead of after the product is imported. Use with CAUTION. This may cause product imports to be drastically slower or fail. [datafeedr]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Import a product's image during a Product Set import/update instead | |
* of after the product is imported. | |
* | |
* Use with CAUTION. This may cause product imports to be drastically slower or fail. | |
* | |
* @see do_action_ref_array(), get_post() | |
* | |
* @param array $post An array of post data including ID, post_title, post_status, etc... | |
* @param array $product An array of product data returned from the Datafeedr API. | |
* @param array $set A post array for this Product Set with an array key of postmeta containing all post meta data. | |
* @param string $action The action the Product Set is performing. Value are either "insert" or "update". | |
*/ | |
add_action( 'dfrpswc_do_product', 'mycode_process_image_on_import', 20, 4 ); | |
function mycode_process_image_on_import( $post, $product, $set, $action ) { | |
if ( $action == 'insert' || $action == 'update' ) { | |
$object = get_post( $post['ID'] ); | |
do_action_ref_array( 'the_post', array( &$object ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment