Page 1 of 1
s09e05 - Grouped Products SUPPORT / QUESTIONS / CHAT
Posted: Tue Jun 06, 2023 11:10 am
by Pierre_P
Addon:
Allows shopowner to create and display "groups" of products.
Download:
viewtopic.php?f=28&t=852
--
Running into something for this groups but i cannot figure it out.
When showing products that is in a group at example group.php?groups_id=6 there are 2 items
Inspecting the html side the stock is reported as 0 looking at data-in-stock="0"
The product or any other product i tried shows same and do have stock.
Looking at my template override product_card.php the 'data-in-stock' => (int)$product->get('in_stock') is working correctly on all other pages except for groups page.
This is causing my add to cart button to show my out of stock button
Store = 1.0.8.21
Any advice please.
Re: s09e05 - Grouped Products
Posted: Tue Jun 06, 2023 11:47 am
by burt
Try changing the $listing_sql to
Code: Select all
$listing_sql = sprintf(<<<'EOSQL'
SELECT m.*, %s
FROM
products_description pd
INNER JOIN products p ON p.products_id = pd.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
LEFT JOIN specials s ON p.products_id = s.products_id
LEFT JOIN (SELECT products_id, COUNT(*) AS attribute_count FROM products_attributes GROUP BY products_id) a ON p.products_id = a.products_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p.products_id in (%s)
EOSQL
, Product::COLUMNS, (int)$_SESSION['languages_id'], $group_links['links']);
Re: s09e05 - Grouped Products
Posted: Tue Jun 06, 2023 2:02 pm
by Pierre_P
burt wrote: ↑Tue Jun 06, 2023 11:47 am
Try changing the $listing_sql to
Thanks Burt
This solved the data-in-stock showing correctly now.
Re: s09e05 - Grouped Products
Posted: Tue Feb 20, 2024 7:50 pm
by tessthepup
@burt
I have been trying to change the code to show the groups in a dropdown rather than a list but I keep breaking the code when using 'new Select'
Code: Select all
echo '<a href="' . $GLOBALS['Linker']->build('group.php', ['groups_id' => (int)$groups['groups_id']]) . '" class="list-group-item list-group-item-action' . $active . '">' . $groups['groups_name'] . '</a>';
Any tips/hints or an example to look at on github to aid me?
Thanks
Mark
Re: s09e05 - Grouped Products
Posted: Tue Feb 20, 2024 10:40 pm
by burt
The closest example would be the manufacturers sidebox.
I think that has both a list code and a dropdown code.
Do remember that if you use a dropdown it needs to be in a <form
THis is also shown in the manufacturers sidebox template file.
--
I haven't looked at these Supporters Codes in a very long time, this one probably since the day I released it.
If you need me to look at it in more depth, I can install it and try, if there is a small Beer budget.
Re: s09e05 - Grouped Products
Posted: Wed Feb 21, 2024 11:09 am
by tessthepup
burt wrote: ↑Tue Feb 20, 2024 10:40 pm
The closest example would be the manufacturers sidebox.
I think that has both a list code and a dropdown code.
Do remember that if you use a dropdown it needs to be in a <form
THis is also shown in the manufacturers sidebox template file.
--
I haven't looked at these Supporters Codes in a very long time, this one probably since the day I released it.
If you need me to look at it in more depth, I can install it and try, if there is a small Beer budget.
@burt
Thanks Gary if you pm me the small beer budget I might let you run with it
Re: s09e05 - Grouped Products
Posted: Wed Feb 21, 2024 12:46 pm
by burt
A newly reserved word in SQL is "groups", which means this addon no longer plays nicely if you are on an up-to-date version of Maria/MySQL.
So, if you run into the same problem as I had, change SQL in the groups addon from (eg);
Code: Select all
$groups_query = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT g.*, gi.*
FROM groups g, groups_info gi
WHERE g.groups_id = gi.groups_id AND gi.languages_id = %d
ORDER BY sort_order, groups_name
EOSQL
, (int)$_SESSION['languages_id']));
to
Code: Select all
$groups_query = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT g.*, gi.*
FROM `groups` g, `groups_info` gi
WHERE g.groups_id = gi.groups_id AND gi.languages_id = %d
ORDER BY sort_order, groups_name
EOSQL
, (int)$_SESSION['languages_id']));
IE, add backticks around the table names.
Note that this is a quickfix.
I unfortunately don't have time in hand to rewrite the addon, but it might be the case that it needs to be re-written slightly (along with a name change from "groups" to (eg) product_groups or somesuch).