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
Introduce UpdateCombinationFromListCommand #22277
Introduce UpdateCombinationFromListCommand #22277
Conversation
07e40a4
to
4c62f0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this PR is WIP and is blocked by another PR, so don't bother, I'm aware 😛 |
f76fd02
to
3b6e527
Compare
@@ -92,7 +92,7 @@ public function createCombinations(ProductId $productId, array $groupedAttribute | |||
$this->disableSpecificPriceRulesApplication(); | |||
|
|||
$combinationIds = $this->addCombinations($product, $generatedCombinations); | |||
$this->updateProductDefaultCombination($productId); | |||
$this->combinationRepository->refreshDefaultCombination($productId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not useful any more since in the loop that adds combination you use combinationRepository->create
which already calls refreshDefaultCombination
internally (at least when no combination is already set as default)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Actually object model updates default combination after each add/update, so I've removed this completely.
df9afd3
to
010d611
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small feedback
src/Adapter/Product/Combination/CommandHandler/UpdateCombinationFromListingHandler.php
Outdated
Show resolved
Hide resolved
src/Adapter/Product/Combination/CommandHandler/UpdateCombinationFromListingHandler.php
Show resolved
Hide resolved
} | ||
|
||
if (null !== $command->getQuantity()) { | ||
//@todo: should we deprecate combination->quantity and product->quantity (as we did with location?) because stock_advanced is the real source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kpodemski do you have some history about it? do you know if it's safe to say stock_advanced
is the current standard field for quantity, and combination->quantity and product->quantity are fields used in the past and now deprectaed (but kept for backward compatibility)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's true, some ERPs are still integrated into it to put here real product quantity but from what I know this field is not really used in any part of the system anymore, replaced via StockAvailable
use PrestaShop\PrestaShop\Core\Domain\Product\Combination\Command\UpdateCombinationFromListingCommand; | ||
|
||
/** | ||
* Defines contract to handle @see UpdateCombinationFromListingCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Defines contract to handle @see UpdateCombinationFromListingCommand | |
* Defines contract to handle @see UpdateCombinationFromListingCommand | |
* | |
* To update combination from listing is the action triggered by a Back Office user from the combinations listing interface. |
I'l wondering if we should start to be more descriptive? 🤔
Some Queries/Commands have very explanatory names, they dont need descriptions. But others are more ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I agree a little bit more description is useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up until now I thought we describe what command does in the command (not in handler).
UpdateCombinationFromListingCommand has this comment Updates combination in list of combinations
. Isn't that enough? Should we start describing usecases inside Handlers from now on?
But, actually I would prefer mentioning handlerInterface inside a command instead of mentioning command inside a handler (because handler already has the command in contract). Then Indeed we could document the handler itself (because that is the class that actually does all the work)
} | ||
|
||
/** | ||
* @Given product :productReference should not have a default combination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @Given product :productReference should not have a default combination | |
* @Given product :productReference does not have a default combination |
* | ||
* @param string $productReference | ||
*/ | ||
public function assertProductHasNoCachedDefaultCombination(string $productReference): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertProductHasNoCachedDefaultCombination
Does that mean we could have a usecase where there is no "cached" default combination but database would have one?
I think (not sure) that Behat tests should ignore cache results 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually related to product->cache_default_attribute field in database.
This field is used as a shortcut to find current default combination id as well as determining if product is combinational
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's the database field name which is confusing
src/Adapter/Product/Combination/CommandHandler/UpdateCombinationFromListingHandler.php
Show resolved
Hide resolved
src/Adapter/Product/Combination/CommandHandler/UpdateCombinationStockHandler.php
Show resolved
Hide resolved
@zuk3975 Need rebase ;) |
c76dc8e
to
7b61775
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good to me, except the suggestions from @matks about comments that can be improved, although it's not blocking to me
|
||
$this->combinationStockUpdater->update( | ||
$command->getCombinationId(), | ||
new CombinationStockProperties($command->getQuantity()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice ^^
@@ -42,28 +41,6 @@ | |||
*/ | |||
class ProductValidator extends AbstractObjectModelValidator | |||
{ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much simpler now 😅
use PrestaShop\PrestaShop\Core\Domain\Product\Combination\Command\UpdateCombinationFromListingCommand; | ||
|
||
/** | ||
* Defines contract to handle @see UpdateCombinationFromListingCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I agree a little bit more description is useful
* | ||
* @param string $productReference | ||
*/ | ||
public function assertProductHasNoCachedDefaultCombination(string $productReference): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's the database field name which is confusing
… closer to related DTO naming
…freshes it after each add/update)
5b4dbca
to
d75e55b
Compare
This change is
StockAvailable related deprecations (#23076)
Product->quantity
&Combination->quantity
. Use StockAvailable->quantity insteadProduct->out_of_stock
. Use StockAvailable->out_of_stock insteadAdvanced stock related deprecations
Product->use_advanced_stock_management
- advanced stock feature is no longer maintained (it was removed in ~1.7)Product->depends_on_stock
&StockAvailable->depends_on_stock
- this property was only relevant with advanced stock feature. That was suggested by following comments found in code and by the fact that usages in code doesn't tell anything against it: