How to debug a serial generator plugin?

  • Posts: 11
  • Thank you received: 0
8 years 2 months ago #229588

-- HikaShop version -- : 2.6.1
-- HikaSerial version -- : 1.10.2
-- Joomla version -- : 3.4.8

Hi,
I'm working on a custom serial generator plugin.
Now I need to debug my code.

But I can't find a way to execute/call the generate hook/method.
Can you tell me the url to manually call it for a certain order ID / pack ID?
That would make thinks way easier for me.

Thanks!

Last edit: 8 years 2 months ago by yoolabs.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
8 years 2 months ago #229607

Hi,

In order to test my generator plugins in HikaSerial, I generally use the "generate" button when you edit a pack.
You first need to assign the generator with your pack and then, the button will be available in the toolbar.
But that generation do not use any order ID.

So, if you want to test with an order ID ; you can create a new order in your HikaShop backend, add a virtual product, change the order into "confirmed" and then use the "Add pack" button.
Once you have added a pack to the order ; you can use the button "refresh associations" to call the generation.
The idea is to delete or unassign the serial (in the serial listing) and then re-click on the "refresh association" to force the creation of a new serial thanks to your plugin.

Let me know if you need further details.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 11
  • Thank you received: 0
8 years 2 months ago #229641

Hi Jerome,

I tried the 'generate' button. Works nicely but I really need to test it with an order as the generator requires product details.

Unfortunately I had no success to use the add pack / refresh associations button.
(the add pack function seems weird, I have to add qty > 1 or refresh the page to see it has been added.)

Then, when I click refresh associations, *nothing* seems to happen.
Seems like my generator function isn't even called.
At the moment, my generate function will just log some debug infos, and I verified it works in pack generation.
But it doesn't seem to be called when refreshing associations.
Maybe my pack settings aren't correct?

For debugging I stripped my generate function down to:

public function generate(&$pack, &$order, $quantity, &$serials) {
		$debuginfo = '';
		$serial = 'xx';
		$debuginfo.= print_r($pack,true)."\n\n\n";
		$debuginfo.= print_r($order,true)."\n\n\n";
		file_put_contents(__DIR__.'/debug.log',$debuginfo);

		for($q = 0; $q < $quantity; $q++) {
			$serial = $serial.'_reply';
			$serials[] = $serial;
		}

		return true;
	}

Any idea why it is not being called?

Last edit: 8 years 2 months ago by yoolabs.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
8 years 2 months ago #229661

Hi,

The "Add pack" will call the "refresh association" directly after you validate the mini-form.
Your currently need to refresh the order page ; the reload in Ajax is unfortunately, not for right now.
Once you have added your pack (and refresh the page), you just need to use the "refresh associations" to re-generate the missing serials. That's why you need to delete them in another tab.

Otherwise refresh association will call your generator as long as your pack is configure to not use a "pack data".
See : www.hikashop.com/support/documentation/1...ition.html#pack_data

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 11
  • Thank you received: 0
8 years 2 months ago #229663

Hi Jerome, you were too fast ;)
I was just about to post new info about the problem.

My pack is set up to use no pack data.

Clicking refresh associations will always remove existing serials but not generate new ones.
I tracked down the executed task to refresh() function in admin hikaserial/classes/order.php.

Last lines of the function are:

		if(in_array($order->order_status, $statuses)) {
			$this->assignSerials($order);
		} else {
			$this->unassignSerials($order);
		}

now, for some reason $statuses will always be an array with the only entry being an empty string - array( 0=>"" ).
Which ends in serials always being unassigned.
Statuses array is assigned by hikaserial config vars assignable_order_statuses or order_confirmed_status.
Both don't seem to exist when I dump hikaserial::config(false).

I checked hikaserial configuration in backend but I couldn't find settings with matching or similar names.

So my current question is: What should I do to make sure $statuses array is filled with correct entries?

Thanks for your help :)

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
8 years 2 months ago #229666

Hi,

Does your order confirmed ?
Is HikaSerial configured correctly for the "assignable order statuses" ?
www.hikashop.com/support/documentation/1...nable_order_statuses

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 11
  • Thank you received: 0
8 years 2 months ago #229677

Weird. It's working now.
Didn't really change anything though.
Maybe a configuration resave or something fixed it. :)

One last question.
Seems refresh associations doesn't generate the serial,
if there already is a serial assigned. Is this the desired behaviour?
If so, is there a way to force the re-generation, even if they already were generated?

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
8 years 2 months ago #229679

Once you have added your pack (and refresh the page), you just need to use the "refresh associations" to re-generate the missing serials. That's why you need to delete them in another tab.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: yoolabs

Please Log in or Create an account to join the conversation.

  • Posts: 11
  • Thank you received: 0
8 years 2 months ago #229782

Ah now I do understand what you were telling me :)
Great everything's working perfectly now.
Thanks for your help Jerome!

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.067 seconds
Powered by Kunena Forum