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

New dashboard page to quickly update stock quantities? #738

Closed
mlocati opened this issue Feb 13, 2023 · 20 comments
Closed

New dashboard page to quickly update stock quantities? #738

mlocati opened this issue Feb 13, 2023 · 20 comments

Comments

@mlocati
Copy link
Contributor

mlocati commented Feb 13, 2023

I'm planning to build a website for a friend of mine.
She has a physical store, and she wants to start selling online too.
For that reason, she needs to update the available quantities for products when she sells something in the physical shop.

At the moment, updating the available quantity is rather overcomplicated for someone that only needs to do that.

Would you accept a PR that adds a new dashboard page only for that purpose?
Of course, I can create a separated package, but I was wondering if it's a requirement that others too may have...

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 13, 2023

I've had others comment on the potential of being able to edit product fields, like the price, or the availability, from the product list screen.

That makes some sense to me, but it may also work a little better on its own dashboard page, where it would be specifically designed for bulk editing.

Perhaps it makes sense at this stage to still build it as a seperate package, where it can be selectively installed if needed (and also more easily modified at for different purposes). Down the track, if it make sense to do so it wouldn't be difficult to just add it to the main store package.

@mlocati
Copy link
Contributor Author

mlocati commented Feb 13, 2023

I agree.

Should I publish that package under the https://github.com/concretecms-community-store umbrella? Otherwise I'd publish it under https://github.com/concrete5-community

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 13, 2023

I reckon under https://github.com/concretecms-community-store

@mlocati
Copy link
Contributor Author

mlocati commented Feb 13, 2023

Yeah, much better.
What about the package handle? community_store_quickquantities would work?

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 13, 2023

Perhaps something a bit more generic, like community_store_bulk_product_updating, since I could imagine that the same page could be useful for updating different product information, not just quantities. (but I understand you'd just be building it for quantities yourself)

@mlocati
Copy link
Contributor Author

mlocati commented Feb 13, 2023

like community_store_bulk_product_updating

👍

If you create that repo and give write access to me, I'll create it asap

@mlocati
Copy link
Contributor Author

mlocati commented Feb 14, 2023

I've pushed some code to https://github.com/concretecms-community-store/community_store_bulk_product_updating

@Mesuva I'm not very familiar with Communiy Store: do you think that the criterias I wrote here and here are ok?

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 14, 2023

@mlocati Both those sections look good to me, at a glance at least - that join looks how I'd expect.

Also cool to see vuejs in your add-on, I think that's the first time I've spotted someone else using it with Concrete.

@mlocati
Copy link
Contributor Author

mlocati commented Feb 14, 2023

Thank for confirming, Ryan!

Yep, I use vue whenever possible (I use jQuery only for ajax requests nowadays 😉)

@mlocati
Copy link
Contributor Author

mlocati commented Feb 15, 2023

@Mesuva I'm done with https://github.com/concretecms-community-store/community_store_bulk_product_updating

If you can/want to take a look at it, please let me know.
Otherwise I'll update its README with some instructions, and publish version 1.0.0

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 17, 2023

@mlocati I've taken a quick look at the add-on. Just a couple of questions:

  • when I first visit the page, do I have to perform a search, or should I expect products to start listing?
  • is there some criteria for products to be listed here? (I'm not getting any listed, even with a search, but I have active products with quantities)
  • I'm getting the attached error as well
    Screen Shot 2023-02-17 at 4 47 23 pm

@mlocati
Copy link
Contributor Author

mlocati commented Feb 18, 2023

when I first visit the page, do I have to perform a search, or should I expect products to start listing?

Yep: that's what users read when they visit the page:
immagine

is there some criteria for products to be listed here? (I'm not getting any listed, even with a search, but I have active products with quantities)

Yep, but you need to enter some search criteria and hit the magnifying class icon.

I'm getting the attached error as well

Whoops: I tested the code only for products that have mandatory variants.
In this case, the page only lets you see and update the quantities of the variants, and it doesn't display the "base" products.
I've fixed this issue (and I've also addressed another v8↔️v9 incompatibility).

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 20, 2023

This is working well for me now.

I'm wondering if something like this is more useful if you don't have to do a search query first - it would just show all products, and you could work your way through them all without having to known what to search for.

@mlocati
Copy link
Contributor Author

mlocati commented Feb 20, 2023

Well, if people have thousands of products/product variations, that would be a huge page...
Maybe we could show all the products if there are less than a predefined number (eg 200)?

@Mesuva
Copy link
Collaborator

Mesuva commented Feb 20, 2023

Is it not paginated?

@mlocati
Copy link
Contributor Author

mlocati commented Feb 20, 2023

Nope

@mlocati
Copy link
Contributor Author

mlocati commented Feb 20, 2023

Adding pagination is rather cumbersome.

The records are fetched by this query, which basically retrieves the products, product options, product variations, and product variation options in just one query.

That's done to avoid hundreds of queries (it's faster to retrieve all product data in just one query, instead of executing a query for every product).

The downside of this is that we can't easily add pagination: how may records should the results be limited to, provided that a single product may span multiple rows returned by that query?

@mlocati
Copy link
Contributor Author

mlocati commented Feb 20, 2023

Just for reference, here's that big query (I've simplified it a bit):

SELECT
    StoreProducts.*,
    CommunityStoreProductOptions.*,
    CommunityStoreProductVariations.*,
    CommunityStoreProductVariationOptionItems.*,
    CommunityStoreProductOptionItems.*
FROM
    StoreProducts
    LEFT JOIN CommunityStoreProductOptions
        ON StoreProducts.pID = CommunityStoreProductOptions.pID
    LEFT JOIN CommunityStoreProductVariations
        ON StoreProducts.pID = CommunityStoreProductVariations.pID
    LEFT JOIN CommunityStoreProductVariationOptionItems
        ON CommunityStoreProductVariations.pvID = CommunityStoreProductVariationOptionItems.pvID
    LEFT JOIN CommunityStoreProductOptionItems
        ON CommunityStoreProductVariationOptionItems.poiID = CommunityStoreProductOptionItems.poiID
    LEFT JOIN CommunityStoreProductVariations AS CommunityStoreProductVariationsWhere
        ON StoreProducts.pID = CommunityStoreProductVariationsWhere.pID
        AND (StoreProducts.pVariations = 1
        AND (CommunityStoreProductVariationsWhere.pvDisabled IS NULL OR CommunityStoreProductVariationsWhere.pvDisabled = 0))
WHERE
    StoreProducts.pActive = 1
    AND (StoreProducts.pDateAvailableStart IS NULL OR StoreProducts.pDateAvailableStart < '2023-02-20 19:59:40')
    AND (StoreProducts.pDateAvailableEnd IS NULL OR StoreProducts.pDateAvailableEnd > '2023-02-20 19:59:40')
    AND (
        (
            StoreProducts.pName LIKE '%search%'
            OR StoreProducts.pSKU LIKE '%search%'
            OR StoreProducts.pBarcode LIKE '%search%'
            OR StoreProducts.pDesc LIKE '%search%'
            OR CommunityStoreProductVariationsWhere.pvSKU LIKE '%search%'
            OR CommunityStoreProductVariationsWhere.pvBarcode LIKE '%search%'
        )
        AND
        (
            StoreProducts.pName LIKE '%me%'
            OR StoreProducts.pSKU LIKE '%me%'
            OR StoreProducts.pBarcode LIKE '%me%'
            OR StoreProducts.pDesc LIKE '%me%'
            OR CommunityStoreProductVariationsWhere.pvSKU LIKE '%me%'
            OR CommunityStoreProductVariationsWhere.pvBarcode LIKE '%me%'
        )
    )
ORDER BY
    StoreProducts.pName ASC,
    StoreProducts.pSKU ASC,
    CommunityStoreProductOptions.poSort ASC,
    CommunityStoreProductVariations.pvSort ASC

@mlocati
Copy link
Contributor Author

mlocati commented Jun 17, 2023

It has been rather hard, but I've updated that package: it now supports pagination.

@mlocati
Copy link
Contributor Author

mlocati commented Jul 2, 2023

Done.

@mlocati mlocati closed this as completed Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants