-
Notifications
You must be signed in to change notification settings - Fork 257
Adapt composite product salability status after reservation was placed. #3056
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
Open
nmalevanec
wants to merge
68
commits into
magento:develop
Choose a base branch
from
nmalevanec:MSI-3054
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 42 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
1721551
magento/inventory#3013: [Async Salable Status] Storefront implementat…
4bc0e48
Add queues for reservation placed
nuzil 53a64b2
[Async Salable Status] Create infrastructure for async status update …
novikor 169e2b3
[Async Salable Status] Create infrastructure for async status update …
novikor 4e2f0a1
Merge branch '1.2.0-develop' into async-reservation
novikor a24043e
[Async Salable Status] Create infrastructure for async status update …
novikor 8e5c2c1
[Async Salable Status] Create infrastructure for async status update …
novikor 813617b
[Async Salable Status] Create infrastructure for async status update …
novikor a72947b
Merge remote-tracking branch 'origin/Lightweight-Is-Are-Product-s-Sal…
novikor 9f0b607
Merge remote-tracking branch 'origin/async-reservation' into faster-s…
novikor fb43921
Revert "[Async Salable Status] Create infrastructure for async status…
novikor 749cb4d
Merge branch 'async-reservation' into faster-storefront
novikor 7663d03
magento/inventory#3013: [Async Salable Status] Storefront implementat…
a9ca49f
magento/inventory#3013: [Async Salable Status] Storefront implementat…
5a16117
magento/inventory#3013: [Async Salable Status] Storefront implementat…
11a7e29
magento/inventory#3013: [Async Salable Status] Storefront implementat…
f176c1a
magento/inventory#3013: [Async Salable Status] Storefront implementat…
874c152
Merge branch '1.2.0-develop' into Lightweight-Is-Are-Product-s-Salable
swnsma 6649831
[Async Salable Status] Create infrastructure for async status update …
novikor b5c9488
Merge remote-tracking branch 'origin/Lightweight-Is-Are-Product-s-Sal…
novikor f4949ba
Merge pull request #3026 from magento/async-reservation
novikor 067a706
[Async Salable Status] Create infrastructure for async status update …
novikor 3ae30ea
[Async Salable Status] Create infrastructure for async status update …
novikor abe49de
[Async Salable Status] Create infrastructure for async status update …
novikor 0abdaab
Fix tests.
nmalevanec b627df2
Fix static tests.
c251753
Remove qty check during setQty method. Move Qty check before persist.
e5aaae5
[Async Salable Status] Moved product salability calculation from obse…
novikor 30cf0af
Merge pull request #3045 from magento/is-product-salable-performance-…
novikor 9cd6d18
Merge pull request #3044 from magento/case-2-set-qty-event
novikor 4135e7a
Merge branch '1.2.0-develop' into faster-storefront
nmalevanec 90c3f0a
[Async Salable Status] Moved plugins to isAvailable only.
novikor 881d150
Merge branch '1.2.0-develop' into faster-storefront
15d5049
Fixed plugin configuration
25859d0
Fix tests.
nmalevanec e27d74e
Fix tests.
nmalevanec 372ac73
Fix salable logic
f761396
Disable configurable condition
a06648d
Fix tests.
nmalevanec 9aea1b4
Fix tests.
nmalevanec b71d884
Fix tests.
nmalevanec 3c29f98
Fix tests.
nmalevanec a6a4d75
Merge branch '1.2.0-develop' into MSI-3054
swnsma 657ccca
Adapt isProductSalabe for bundle and configurable products.
nmalevanec 438050a
Merge remote-tracking branch 'origin/MSI-3054' into MSI-3054
nmalevanec 995d5aa
Remove redundant plugin.
nmalevanec 74da690
Fix tests
nmalevanec 4d6eb63
Remove MySQL view. Re-work bundle product indexer.
nmalevanec 7e0e09d
Re-work configurable product indexer. Modify is salable condition.
nmalevanec 7744314
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec 58889f0
Re-work bundle product indexer.
nmalevanec 4f9f97c
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec 8d6a3ec
Fix merge conflicts.
nmalevanec 41fbb07
Fix configurable product is salable verification.
nmalevanec c0e5cdf
Fis bundle product indexation.
nmalevanec 674df26
Fix website value for IsSalable service.
nmalevanec ad4ff2e
Rework configurable product salable verification. Rework AreProductsS…
nmalevanec a1ff326
Fix 'is_salable' and 'is_available' plugins. Make index to consider m…
nmalevanec 5eafe30
Try to remove plugin blocked used events.
nmalevanec 8cffa9e
Fix test.
nmalevanec 53f6bc5
Fix bundle product index. Fix adapt get product stock status plugins.
nmalevanec 5e9bcca
Fix tests.
nmalevanec 0960dd5
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec b2fae89
Fix adapt get product stock status plugins.
nmalevanec a42afd3
Fix tests.
nmalevanec 0b5e2a3
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec 7e7f12f
Fix tests.
nmalevanec a7e548f
Merge branch '1.2.0-develop' into MSI-3054
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
...ryBundleProduct/Plugin/CatalogInventory/Helper/Stock/AdaptAssignStatusToProductPlugin.php
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...toryCache/Plugin/InventoryIndexer/Queue/Reservation/UpdateSalabilityStatus/CacheFlush.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\InventoryCache\Plugin\InventoryIndexer\Queue\Reservation\UpdateSalabilityStatus; | ||
|
|
||
| use Magento\Framework\Exception\NoSuchEntityException; | ||
| use Magento\InventoryCache\Model\FlushCacheByProductIds; | ||
| use Magento\InventoryCatalogApi\Model\GetProductIdsBySkusInterface; | ||
| use Magento\InventoryIndexer\Model\Queue\UpdateIndexSalabilityStatus; | ||
|
|
||
| /** | ||
| * Clean cache for corresponding products after stock status update. | ||
| */ | ||
| class CacheFlush | ||
| { | ||
| /** | ||
| * @var FlushCacheByProductIds | ||
| */ | ||
| private $flushCacheByIds; | ||
|
|
||
| /** | ||
| * @var GetProductIdsBySkusInterface | ||
| */ | ||
| private $getProductIdsBySkus; | ||
|
|
||
| /** | ||
| * @param FlushCacheByProductIds $flushCacheByIds | ||
| * @param GetProductIdsBySkusInterface $getProductIdsBySkus | ||
| */ | ||
| public function __construct( | ||
| FlushCacheByProductIds $flushCacheByIds, | ||
| GetProductIdsBySkusInterface $getProductIdsBySkus | ||
| ) { | ||
| $this->flushCacheByIds = $flushCacheByIds; | ||
| $this->getProductIdsBySkus = $getProductIdsBySkus; | ||
| } | ||
|
|
||
| /** | ||
| * Flush cache after reindex. | ||
| * | ||
| * @param UpdateIndexSalabilityStatus $subject | ||
| * @param array $skusAffected | ||
| * | ||
| * @return array | ||
| * @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
| */ | ||
| public function afterExecute(UpdateIndexSalabilityStatus $subject, array $skusAffected) | ||
| { | ||
| if ($skus = array_keys($skusAffected)) { | ||
| try { | ||
| $this->flushCacheByIds->execute($this->getProductIdsBySkus->execute($skus)); | ||
| } catch (NoSuchEntityException $e) { // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch | ||
| // Do nothing. | ||
| } | ||
| } | ||
|
|
||
| return $skusAffected; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\InventoryCatalog\Model; | ||
|
|
||
| use Magento\Catalog\Model\Product; | ||
| use Magento\Catalog\Model\Product\Attribute\Source\Status; | ||
| use Magento\InventorySalesApi\Api\AreProductsSalableInterface; | ||
|
|
||
| /** | ||
| * Get salable product status service. | ||
| */ | ||
| class IsProductSalable | ||
| { | ||
| /** | ||
| * @var GetStockIdForCurrentWebsite | ||
| */ | ||
| private $getStockIdForCurrentWebsite; | ||
|
|
||
| /** | ||
| * @var AreProductsSalableInterface | ||
| */ | ||
| private $areProductsSalable; | ||
|
|
||
| /** | ||
| * @var array | ||
| */ | ||
| private $productStatusCache; | ||
|
|
||
| /** | ||
| * @param GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite | ||
| * @param AreProductsSalableInterface $areProductsSalable | ||
| */ | ||
| public function __construct( | ||
| GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite, | ||
| AreProductsSalableInterface $areProductsSalable | ||
| ) { | ||
| $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; | ||
| $this->areProductsSalable = $areProductsSalable; | ||
| } | ||
|
|
||
| /** | ||
| * Verify product salable status. | ||
| * | ||
| * @param Product $product | ||
| * @return bool | ||
| */ | ||
| public function execute(Product $product): bool | ||
| { | ||
| if (null === $product->getSku() || (int)$product->getStatus() === Status::STATUS_DISABLED) { | ||
| return false; | ||
| } | ||
| if ($product->getData('is_salable') !== null) { | ||
| return (bool)$product->getData('is_salable'); | ||
| } | ||
| $stockId = $this->getStockIdForCurrentWebsite->execute(); | ||
| if (isset($this->productStatusCache[$stockId][$product->getSku()])) { | ||
| return $this->productStatusCache[$stockId][$product->getSku()]; | ||
| } | ||
|
|
||
| $stockId = $this->getStockIdForCurrentWebsite->execute(); | ||
| $result = current($this->areProductsSalable->execute([$product->getSku()], $stockId)); | ||
| $salabilityStatus = $result->isSalable(); | ||
| $this->productStatusCache[$stockId][$product->getSku()] = $salabilityStatus; | ||
|
|
||
| return $salabilityStatus; | ||
| } | ||
| } | ||
46 changes: 46 additions & 0 deletions
46
InventoryCatalog/Plugin/Catalog/Model/Type/Simple/IsSalablePlugin.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\InventoryCatalog\Plugin\Catalog\Model\Type\Simple; | ||
|
|
||
| use Magento\Catalog\Model\Product; | ||
| use Magento\Catalog\Model\Product\Type\Simple; | ||
| use Magento\InventoryCatalog\Model\IsProductSalable; | ||
|
|
||
| /** | ||
| * Apply the inventory is-salable result to the according method of the product type model. | ||
| */ | ||
| class IsSalablePlugin | ||
| { | ||
| /** | ||
| * @var IsProductSalable | ||
| */ | ||
| private $isProductSalable; | ||
|
|
||
| /** | ||
| * @param IsProductSalable $isProductSalable | ||
| */ | ||
| public function __construct( | ||
| IsProductSalable $isProductSalable | ||
| ) { | ||
| $this->isProductSalable = $isProductSalable; | ||
| } | ||
|
|
||
| /** | ||
| * Fetches is salable status from multi-stock. | ||
| * | ||
| * @param Simple $subject | ||
| * @param \Closure $proceed | ||
| * @param Product $product | ||
| * @return bool | ||
| * @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
| */ | ||
| public function aroundIsSalable(Simple $subject, \Closure $proceed, Product $product): bool | ||
| { | ||
| return $this->isProductSalable->execute($product); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
InventoryCatalog/Plugin/Catalog/Model/Type/Virtual/IsSalablePlugin.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\InventoryCatalog\Plugin\Catalog\Model\Type\Virtual; | ||
|
|
||
| use Magento\Catalog\Model\Product; | ||
| use Magento\InventoryCatalog\Model\IsProductSalable; | ||
|
|
||
| /** | ||
| * Apply the inventory is-salable result to the according method of the product type model. | ||
| */ | ||
| class IsSalablePlugin | ||
| { | ||
| /** | ||
| * @var IsProductSalable | ||
| */ | ||
| private $isProductSalable; | ||
|
|
||
| /** | ||
| * @param IsProductSalable $isProductSalable | ||
| */ | ||
| public function __construct( | ||
| IsProductSalable $isProductSalable | ||
| ) { | ||
| $this->isProductSalable = $isProductSalable; | ||
| } | ||
|
|
||
| /** | ||
| * Fetches is salable status from multi-stock. | ||
| * | ||
| * @param Product\Type\Virtual $subject | ||
| * @param \Closure $proceed | ||
| * @param Product $product | ||
| * @return bool | ||
| * @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
| */ | ||
| public function aroundIsSalable(Product\Type\Virtual $subject, \Closure $proceed, Product $product): bool | ||
| { | ||
| return $this->isProductSalable->execute($product); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 violates modularity we should not accept and work with product model in inventory modules