Consume serial based on pack

  • Posts: 128
  • Thank you received: 2
7 years 10 months ago #259474

-- HikaShop version -- : 2.6.4
-- HikaSerial version -- : 1.10.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.6

Hi there,

By looking into the Hikaserial.Serial controller code I realised in the consume URL you can pass the Pack ID or Pack Name as a parameter as well. This is not explained here:
www.hikashop.com/support/documentation/1...onsume-features.html

However when trying it out it does not work as there seems to be a bug on the SQL query to retrieve the serial by pack -> see Hikaserial.Serial Class -> function check() -> line 388. The filters seem to added outside the parenthesis

$query = 'SELECT a.*, b.pack_params FROM '.hikaserial::table('serial').' AS a INNER JOIN '.hikaserial::table('pack').' AS b '.
				' ON a.serial_pack_id = b.pack_id '.
				' WHERE (b.pack_published = 1 AND a.serial_data = '.$this->db->Quote($serial_data).') ' . implode(' AND ', $filters);

Anyway, I am wondering if this parameter is required at all. So the question is, if two different packs use the same generator, is it possible that the same serial appears in both packs? In other words, is it possible that there are NOT UNIQUE serials?

If that is the case (there could be repeated serials in different packs), then we need the bug fixed to be able to specify the pack when consuming a serial and avoid that the wrong serial gets consumed.

Thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 10 months ago #259476

Hi,

1 - The filters are added outside the parenthesis yes, but there is no bug there.

2 - I'm not following you.

I realised in the consume URL you can pass the Pack ID or Pack Name as a parameter as well

I am wondering if this parameter is required at all

You saw that there is an optional parameter so you know that this parameter is not required, but optional.

3 - about your last question

is it possible that there are NOT UNIQUE serials?

HikaSerial have options to be sure that generators won't create duplicate data but you can also import and create manually serials in your database. You can also use generators like "series" which can definitively generate the same serials in several packs because it's one of his goal.
By definition, it is possible to have duplicate serials but it's not something that HikaSerial will do itself.
And that is why it is possible to specify the pack id or the pack name during the consumption so you can target a specific pack if you know that the serial can be duplicated depending your configuration and your 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: 128
  • Thank you received: 2
7 years 10 months ago #259507

Thanks Jerome,

OK, now I understand the Pack ID/Name is an optional parameter, maybe you could add this to your documentation?

However when I use it I get an SQL error message, that's why I thought it was a bug:

1064
Error: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b.pack_id = 1' at line 1 SQL=SELECT a.*, b.pack_params FROM #__hikaserial_serial AS a INNER JOIN #__hikaserial_pack AS b ON a.serial_pack_id = b.pack_id WHERE (b.pack_published = 1 AND a.serial_data = 'Hiy4Nsq7JdRD') b.pack_id = 1

So how does Hikaserial ensure that two different generators do not issue the same serial number? Is this a parameter in the config somewhere? Is this built in by default? Anyway, I think to be on the safe side I should use the Pack ID parameter but we need to fix the SQL error.

Many thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 10 months ago #259510

Hi,

Okay, now I see what you're talking about.
In the class file, replace

	' WHERE (b.pack_published = 1 AND a.serial_data = '.$this->db->Quote($serial_data).') ' . implode(' AND ', $filters);
By
	' WHERE (b.pack_published = 1 AND a.serial_data = '.$this->db->Quote($serial_data).')';
	if(!empty($filters))
		$query .= ' AND ' . implode(' AND ', $filters);
And it will add the missing AND.

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.
Last edit: 7 years 10 months ago by Jerome.

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

  • Posts: 128
  • Thank you received: 2
7 years 10 months ago #259522

Thank you, sorted :)

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

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