s09e05 - Grouped Products SUPPORT / QUESTIONS / CHAT

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

s09e05 - Grouped Products SUPPORT / QUESTIONS / CHAT

Post 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.

Tags:


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: s09e05 - Grouped Products

Post 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']);
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
Pierre_P
Contributor
Posts: 144
Joined: Fri Mar 12, 2021 5:06 am
Phoenix Version: v1.1.0.6
Has thanked: 21 times
Been thanked: 11 times

Re: s09e05 - Grouped Products

Post 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.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: s09e05 - Grouped Products

Post 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
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: s09e05 - Grouped Products

Post 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.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: s09e05 - Grouped Products

Post 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
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: s09e05 - Grouped Products

Post 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).


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply