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

Admin category listing to show number of products #3131

Closed
havenswift-hosting opened this issue Jan 13, 2023 · 24 comments
Closed

Admin category listing to show number of products #3131

havenswift-hosting opened this issue Jan 13, 2023 · 24 comments
Assignees
Milestone

Comments

@havenswift-hosting
Copy link

It would be very useful to show a count of the number of products in each category - maybe between "Category Name" and "Translations" columns

@havenswift-hosting havenswift-hosting changed the title Admin category listing to shown number of products Admin category listing to show number of products Jan 20, 2023
@bhsmither
Copy link
Contributor

In categories.index.php, suggest:

From:
      <td>{$LANG.settings.category_name}</td>
      <td>{$LANG.translate.title_translations}</td>
To:
      <td>{$LANG.settings.category_name}</td>
      <td>Prod P/A</td>
      <td>{$LANG.translate.title_translations}</td>
From:
        {$category.cat_name}
        {/if}
        </td>
        <td style="text-align:center" class="language_list">
To:
        {$category.cat_name}
        {/if}
        </td>
        <td style="text-align:center">{$category.pri_alt}</td>
        <td style="text-align:center" class="language_list">

In categories.index.inc.php, suggest:

Near line 445, from:
            $category['children'] = currentPage(null, array('parent' => $category['cat_id']));
            $category['translate'] = currentPage(null, array('action' => 'translate', 'cat_id' => $category['cat_id']));
            $category['edit']  = currentPage(null, array('action' => 'edit', 'cat_id' => $category['cat_id']));
To:
            $cat_sel = $GLOBALS['db']->select('CubeCart_category_index', array('primary'), array('cat_id' => $category['cat_id']));
            $category['pri_alt'] = (array_count_values(array_column($cat_sel, 'primary'))['1'] ?? '--').'/'.(array_count_values(array_column($cat_sel, 'primary'))['0'] ?? '--');
            $category['children'] = currentPage(null, array('parent' => $category['cat_id']));
            $category['translate'] = currentPage(null, array('action' => 'translate', 'cat_id' => $category['cat_id']));
            $category['edit']  = currentPage(null, array('action' => 'edit', 'cat_id' => $category['cat_id']));

The new column will show a number/number that represents the number of products where this category is the primary category, followed by the number of products that claim this category as an alternate category.

@abrookbanks
Copy link
Member

This gives me an error.

categories.index.inc.php:443 - array_column(): Argument #1 ($array) must be of type array, bool given

Will see if I can fix it.

@bhsmither
Copy link
Contributor

So $cat_sel is false because there is nothing in CubeCart_category_index having that 'cat_id'?

Did you create a category without having assigned any products to it yet? Ok, that's legit.

@bhsmither
Copy link
Contributor

This is my fix, although I do not know why this wasn't noticed:

$cat_sel = $GLOBALS['db']->select('CubeCart_category_index', array('primary'), array('cat_id' => $category['cat_id'])) ?: array();

Gives $cat_sel an empty array if nothing found.

@abrookbanks
Copy link
Member

Something still odd. This store has hundreds of products...
Screenshot 2023-04-21 at 08 44 15

@abrookbanks
Copy link
Member

Actually that's right! This shops mostly has products in the subcategory.

@abrookbanks
Copy link
Member

Thanks.

@abrookbanks
Copy link
Member

Should we just show the total? I find this confusing to look at.

@abrookbanks
Copy link
Member

.. sorry for the message trail. Or show total but hover a title saying the primary/additional ratio.

@havenswift-hosting
Copy link
Author

I also find this a bit confusing - I think just a simple count for products in that specific category would be clearer

@abrookbanks
Copy link
Member

I also find this a bit confusing - I think just a simple count for products in that specific category would be clearer

Yes I agree. We can add a title tag for the split.

@abrookbanks
Copy link
Member

Mouse pointer isn't in the screenshot but on hover of the count number we can break it down.
Screenshot 2023-04-21 at 09 13 32

abrookbanks added a commit that referenced this issue Apr 21, 2023
abrookbanks added a commit that referenced this issue Apr 21, 2023
@bhsmither
Copy link
Contributor

Is there a way to indicate additional info available via hover? Maybe append the white 'i' in blue circle icon?

@abrookbanks
Copy link
Member

abrookbanks commented Apr 21, 2023

Does this look weird?
Screenshot 2023-04-21 at 09 29 12

@abrookbanks
Copy link
Member

IMO the ABBR tag looks better.
Screenshot 2023-04-21 at 09 30 52

@abrookbanks
Copy link
Member

On two lines it looks better still.

Screenshot 2023-04-21 at 09 33 27

abrookbanks added a commit that referenced this issue Apr 21, 2023
@abrookbanks
Copy link
Member

I think this is good now. Thanks all.

@bhsmither
Copy link
Contributor

The last edit I see is opening with <abbr> but closing with </span>.

abrookbanks added a commit that referenced this issue Apr 21, 2023
@abrookbanks
Copy link
Member

Thanks. I think the (i) looks bad personally. I've got vision problems at the moment so your QA is much appreciated.

@abrookbanks abrookbanks self-assigned this Apr 21, 2023
@abrookbanks abrookbanks added this to the 6.5.2 milestone Apr 21, 2023
@abrookbanks
Copy link
Member

Maybe a count including all subfolders would be even better.🫣

@bhsmither
Copy link
Contributor

bhsmither commented Apr 22, 2023

Because I run a 4k monitor, these little dots (via <abbr>) are so barely visible - absolutely overlooked unless you know that they are there. Also, personally, the little dots under the number is not familiar to me - I do (did) not know what that means.

@bhsmither
Copy link
Contributor

Might want to give some thought to incorporating the Search icon in the Actions column -- co-opt its tooltip.

@abrookbanks abrookbanks reopened this Apr 23, 2023
abrookbanks added a commit that referenced this issue Jun 29, 2023
@abrookbanks
Copy link
Member

Probably the best overall solution.
Screenshot 2023-06-29 at 14 08 46

@havenswift-hosting
Copy link
Author

That is great thanks !

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

No branches or pull requests

3 participants