Skip to content
Open
Show file tree
Hide file tree
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…
May 8, 2020
4bc0e48
Add queues for reservation placed
nuzil May 6, 2020
53a64b2
[Async Salable Status] Create infrastructure for async status update …
novikor May 9, 2020
169e2b3
[Async Salable Status] Create infrastructure for async status update …
novikor May 9, 2020
4e2f0a1
Merge branch '1.2.0-develop' into async-reservation
novikor May 11, 2020
a24043e
[Async Salable Status] Create infrastructure for async status update …
novikor May 11, 2020
8e5c2c1
[Async Salable Status] Create infrastructure for async status update …
novikor May 11, 2020
813617b
[Async Salable Status] Create infrastructure for async status update …
novikor May 13, 2020
a72947b
Merge remote-tracking branch 'origin/Lightweight-Is-Are-Product-s-Sal…
novikor May 13, 2020
9f0b607
Merge remote-tracking branch 'origin/async-reservation' into faster-s…
novikor May 13, 2020
fb43921
Revert "[Async Salable Status] Create infrastructure for async status…
novikor May 14, 2020
749cb4d
Merge branch 'async-reservation' into faster-storefront
novikor May 14, 2020
7663d03
magento/inventory#3013: [Async Salable Status] Storefront implementat…
May 14, 2020
a9ca49f
magento/inventory#3013: [Async Salable Status] Storefront implementat…
May 14, 2020
5a16117
magento/inventory#3013: [Async Salable Status] Storefront implementat…
May 15, 2020
11a7e29
magento/inventory#3013: [Async Salable Status] Storefront implementat…
May 15, 2020
f176c1a
magento/inventory#3013: [Async Salable Status] Storefront implementat…
May 15, 2020
874c152
Merge branch '1.2.0-develop' into Lightweight-Is-Are-Product-s-Salable
swnsma May 15, 2020
6649831
[Async Salable Status] Create infrastructure for async status update …
novikor May 17, 2020
b5c9488
Merge remote-tracking branch 'origin/Lightweight-Is-Are-Product-s-Sal…
novikor May 17, 2020
f4949ba
Merge pull request #3026 from magento/async-reservation
novikor May 17, 2020
067a706
[Async Salable Status] Create infrastructure for async status update …
novikor May 17, 2020
3ae30ea
[Async Salable Status] Create infrastructure for async status update …
novikor May 17, 2020
abe49de
[Async Salable Status] Create infrastructure for async status update …
novikor May 17, 2020
0abdaab
Fix tests.
nmalevanec May 19, 2020
b627df2
Fix static tests.
May 19, 2020
c251753
Remove qty check during setQty method. Move Qty check before persist.
May 19, 2020
e5aaae5
[Async Salable Status] Moved product salability calculation from obse…
novikor May 19, 2020
30cf0af
Merge pull request #3045 from magento/is-product-salable-performance-…
novikor May 19, 2020
9cd6d18
Merge pull request #3044 from magento/case-2-set-qty-event
novikor May 19, 2020
4135e7a
Merge branch '1.2.0-develop' into faster-storefront
nmalevanec May 20, 2020
90c3f0a
[Async Salable Status] Moved plugins to isAvailable only.
novikor May 20, 2020
881d150
Merge branch '1.2.0-develop' into faster-storefront
May 21, 2020
15d5049
Fixed plugin configuration
May 21, 2020
25859d0
Fix tests.
nmalevanec May 22, 2020
e27d74e
Fix tests.
nmalevanec May 22, 2020
372ac73
Fix salable logic
May 23, 2020
f761396
Disable configurable condition
May 24, 2020
a06648d
Fix tests.
nmalevanec May 25, 2020
9aea1b4
Fix tests.
nmalevanec May 25, 2020
b71d884
Fix tests.
nmalevanec May 26, 2020
3c29f98
Fix tests.
nmalevanec May 27, 2020
a6a4d75
Merge branch '1.2.0-develop' into MSI-3054
swnsma May 27, 2020
657ccca
Adapt isProductSalabe for bundle and configurable products.
nmalevanec May 28, 2020
438050a
Merge remote-tracking branch 'origin/MSI-3054' into MSI-3054
nmalevanec May 28, 2020
995d5aa
Remove redundant plugin.
nmalevanec May 28, 2020
74da690
Fix tests
nmalevanec May 29, 2020
4d6eb63
Remove MySQL view. Re-work bundle product indexer.
nmalevanec Jun 1, 2020
7e0e09d
Re-work configurable product indexer. Modify is salable condition.
nmalevanec Jun 4, 2020
7744314
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec Jun 4, 2020
58889f0
Re-work bundle product indexer.
nmalevanec Jun 4, 2020
4f9f97c
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec Jun 5, 2020
8d6a3ec
Fix merge conflicts.
nmalevanec Jun 5, 2020
41fbb07
Fix configurable product is salable verification.
nmalevanec Jun 5, 2020
c0e5cdf
Fis bundle product indexation.
nmalevanec Jun 9, 2020
674df26
Fix website value for IsSalable service.
nmalevanec Jun 10, 2020
ad4ff2e
Rework configurable product salable verification. Rework AreProductsS…
nmalevanec Jun 11, 2020
a1ff326
Fix 'is_salable' and 'is_available' plugins. Make index to consider m…
nmalevanec Jun 12, 2020
5eafe30
Try to remove plugin blocked used events.
nmalevanec Jun 12, 2020
8cffa9e
Fix test.
nmalevanec Jun 15, 2020
53f6bc5
Fix bundle product index. Fix adapt get product stock status plugins.
nmalevanec Jun 16, 2020
5e9bcca
Fix tests.
nmalevanec Jun 17, 2020
0960dd5
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec Jun 18, 2020
b2fae89
Fix adapt get product stock status plugins.
nmalevanec Jun 18, 2020
a42afd3
Fix tests.
nmalevanec Jun 19, 2020
0b5e2a3
Merge branch '1.2.0-develop' into MSI-3054
nmalevanec Jun 19, 2020
7e7f12f
Fix tests.
nmalevanec Jun 22, 2020
a7e548f
Merge branch '1.2.0-develop' into MSI-3054
Nov 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="navigateToCheckoutPage"/>
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickOnNextButton"/>
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickOnPlaceOrder"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<magentoCLI command="queue:consumers:start inventory.reservations.updateSalabilityStatus" stepKey="updateSalability"/>
<!--Verify, configurable product has 'out of stock' status.-->
<amOnPage url="{{StorefrontProductPage.url($configurableProduct.custom_attributes[url_key]$)}}" stepKey="navigateToConfigurablePDP"/>
<see selector="{{StorefrontProductInfoMainSection.productStockStatus}}" userInput="{{SourceStatusOutOfStock.value}}" stepKey="verifyProductStatus"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="navigateToCheckoutPage"/>
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickOnNextButton"/>
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickOnPlaceOrder"/>

<!-- So far `default` Cron Group contains inventory update -->
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
<magentoCLI command="queue:consumers:start inventory.reservations.updateSalabilityStatus" stepKey="updateSalability"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<!-- Assert out of stock option is absent on product page -->
<amOnPage url="{{StorefrontProductPage.url($$configurableProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToConfigurablePDP"/>
<waitForPageLoad stepKey="waitForConfigurablePDP"/>
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions InventoryBundleProduct/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@
</argument>
</arguments>
</type>
<type name="Magento\CatalogInventory\Helper\Stock">
<plugin name="adapt_assign_stock_status_to_bundle_product" type="Magento\InventoryBundleProduct\Plugin\CatalogInventory\Helper\Stock\AdaptAssignStatusToProductPlugin"/>
</type>
</config>
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;
}
}
3 changes: 3 additions & 0 deletions InventoryCache/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<type name="Magento\InventoryIndexer\Indexer\SourceItem\SourceItemIndexer">
<plugin name="invalidate_products_cache" type="Magento\InventoryCache\Plugin\InventoryIndexer\Indexer\Source\SourceItemIndexer\CacheFlush"/>
</type>
<type name="Magento\InventoryIndexer\Model\Queue\UpdateIndexSalabilityStatus">
<plugin name="invalidate_products_cache" type="Magento\InventoryCache\Plugin\InventoryIndexer\Queue\Reservation\UpdateSalabilityStatus\CacheFlush" />
</type>
<type name="Magento\InventoryCache\Model\ResourceModel\GetProductIdsByStockIds">
<arguments>
<argument name="productTableName" xsi:type="string">catalog_product_entity</argument>
Expand Down
73 changes: 73 additions & 0 deletions InventoryCatalog/Model/IsProductSalable.php
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
Copy link
Copy Markdown
Contributor

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

{
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;
}
}
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);
}
}
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);
}
}
Loading