Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After import action should pass user selected data #120

Open
JiveDig opened this issue Sep 14, 2018 · 7 comments
Open

After import action should pass user selected data #120

JiveDig opened this issue Sep 14, 2018 · 7 comments

Comments

@JiveDig
Copy link

JiveDig commented Sep 14, 2018

Right now merlin_after_all_import only passes selected_import_index. IMO it would be better to also (or in place of) pass the data from get_import_data_info(). This would allow devs to only run certain after_import code depending on what options the user has selected.

I just hit this issue during testing. If the user has selected to import content I want to run code, but not any other time.

@aurora-hq
Copy link

aurora-hq commented Sep 14, 2018

I agree, but I also found a workaround using the index.
For example:

function merlin_after_import_setup_function ( $selected_import_index ) {
	
	// Grab the selected import file.
	$selected_import_file = $GLOBALS['wizard']->import_files[ $selected_import_index ];
	/* $GLOBALS['wizard'] is the default Merlin class instance defined in "merlin-config.php", 
	   you could call it something else if you'd like. */
	
	// You may access the currently selected import file like so:
	if ( 'Some Demo Name' === $selected_import_file['import_file_name'] ) {
		// Do something for this particular demo...
	}
		
}
add_action( 'merlin_after_all_import', 'merlin_after_import_setup_function' );

I hope this helps.

@JiveDig
Copy link
Author

JiveDig commented Sep 18, 2018

To clarify, my current multi-demo testing has options for "Business" and "News" demo/configurations. I want to run some code on merlin_after_all_import hook "if importing Business demo && importing content".

I don't see a way to do this right now.

@JiveDig JiveDig mentioned this issue Oct 5, 2018
@JiveDig
Copy link
Author

JiveDig commented Oct 5, 2018

I'm thinking a simple solution may be to convert get_import_data_info() or get_import_data() to a static method. That way during merlin_after_all_import we could use:
Merlin::get_import_data_info( $selected_import_index ) to get the data and conditionally run some code based on which import was selected.

I'm not sure if this is the best approach, still seems easier to just pass that data like:

public function after_all_import_action( $selected_import_index, $import_data ) {

but that may take more refactoring I'm unaware of.

@monparaashvin
Copy link

Right now merlin_after_all_import only passes selected_import_index. IMO it would be better to also (or in place of) pass the data from get_import_data_info(). This would allow devs to only run certain after_import code depending on what options the user has selected.

I just hit this issue during testing. If the user has selected to import content I want to run code, but not any other time.

I agree, but I also found a workaround using the index.
For example:

function merlin_after_import_setup_function ( $selected_import_index ) {
	
	// Grab the selected import file.
	$selected_import_file = $GLOBALS['wizard']->import_files[ $selected_import_index ];
	/* $GLOBALS['wizard'] is the default Merlin class instance defined in "merlin-config.php", 
	   you could call it something else if you'd like. */
	
	// You may access the currently selected import file like so:
	if ( 'Some Demo Name' === $selected_import_file['import_file_name'] ) {
		// Do something for this particular demo...
	}
		
}
add_action( 'merlin_after_all_import', 'merlin_after_import_setup_function' );

I hope this helps.

i use this code but not working.
show this links:-#165

@aurora-hq
Copy link

@monparaashvin make sure the $GLOBALS['wizard'] matches what's been defined as the Merlin class instance in "merlin-config.php", that's key. If you changed it then update the code respectively.
I hope that helps!

@monparaashvin
Copy link

monparaashvin commented May 9, 2019

@monparaashvin make sure the $GLOBALS['wizard'] matches what's been defined as the Merlin class instance in "merlin-config.php", that's key. If you changed it then update the code respectively.
I hope that helps!

i have some code update merlin-config.php.
all data successfully import but one issues in front page is not selected.

@aurora-hq
Copy link

not sure why it's not working for you, works for me. Do some debugging, maybe you have a typo somewhere...
Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants