concretecms-community-store / community_store

An open, free and community developed eCommerce system for Concrete CMS
https://concretecms-community-store.github.io/community_store/
MIT License
106 stars 66 forks source link

Better check if we need to update product quantities #814

Closed mlocati closed 9 months ago

mlocati commented 10 months ago

The update() method of the brand new AutoUpdaterQuantitiesFromVariations class checks if we need to update the product quantities. In order to do that, we need to know the actual value of the pQty (and pQtyUnlim) of the products, without considering the possibly associated variations. It seems to me it's impossible to to that at the moment, so I think we need two new methods (getProductStockLevel and isProductUnlimited) to retrieve these two values.

I've also added 6106689fcab0ac74bfd78b80b8d96e306d7d9e22 (a minor optimization that I forgot to add to #813).

mlocati commented 9 months ago

@Mesuva have you had the chance to take a look at this PR?

Mesuva commented 9 months ago

Sorry, I hadn't forgotten about it (it's still on my whiteboard), just time has slipped away from me over the last month.

Will do so this week.

Mesuva commented 9 months ago

I've merged this, and obviously the previous work that relates to it.

However, I've just realised that it introduces a new Task, and we're actually still trying to support V8 sites with this version of Community Store. Do you think we could handle both this and a V8 compatible job?

But from what I tested though it all worked well and made sense.

mlocati commented 9 months ago

There's also a Job: https://github.com/concretecms-community-store/community_store/blob/master/jobs/auto_update_quantities_from_variations.php

mlocati commented 9 months ago

PS: on v8 we install the job, and on v9 both the job and the task.

BTW they should be both optional: the product quantities should be automatically kept up to date by https://github.com/concretecms-community-store/community_store/blob/master/src/CommunityStore/Utilities/DoctrineORMEventsSubscriber.php, but I still preferred to add a schedulable way to keep the qualities updated just in case

Mesuva commented 9 months ago

Sorry Michele, I didn't look hard enough and hadn't seen the job! Fantastic work, thanks again. I'll put out a release next week I think.

Mesuva commented 8 months ago

Hey @mlocati, I've just tried this code out on a V8 site and I've hit a problem. It's trying to autoload the classes from /src/CommunityStore/Command, and those reference classes in V9 that don't exist in V8, crashing a site.

I'm trying to think of a way to only autoload those classes if under V9, but I haven't found a way to do this. Any suggestions?

mlocati commented 8 months ago

I'm checking it right now

mlocati commented 8 months ago

I think I understand what's happening: since we don't specify a directory containing the Doctine entities, Doctrine parses all the .php files in the package directory in order to detect the entities.

This implies that Doctrine also loads the v9-specific files, which obviously are missing some classes.

I'm going to look for a solution.

mlocati commented 8 months ago

820 should fix this issue.