Skip to content

Commit 7f54568

Browse files
committed
MC-19672: Simple product disappearing in the configurable grid after qty set to 0
1 parent 59b1140 commit 7f54568

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

app/code/Magento/ConfigurableProduct/Model/Plugin/Frontend/UsedProductsCache.php renamed to app/code/Magento/ConfigurableProduct/Model/Plugin/UsedProductsCache.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\ConfigurableProduct\Model\Plugin\Frontend;
8+
namespace Magento\ConfigurableProduct\Model\Plugin;
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
1212
use Magento\Catalog\Model\Category;
1313
use Magento\Catalog\Model\Product;
1414
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1515
use Magento\Customer\Model\Session;
16+
use Magento\Framework\App\State as AppState;
1617
use Magento\Framework\Cache\FrontendInterface;
1718
use Magento\Framework\EntityManager\MetadataPool;
1819
use Magento\Framework\Serialize\SerializerInterface;
@@ -24,6 +25,11 @@
2425
*/
2526
class UsedProductsCache
2627
{
28+
/**
29+
* @var AppState
30+
*/
31+
private $appState;
32+
2733
/**
2834
* @var MetadataPool
2935
*/
@@ -50,19 +56,22 @@ class UsedProductsCache
5056
private $customerSession;
5157

5258
/**
59+
* @param AppState $appState
5360
* @param MetadataPool $metadataPool
5461
* @param FrontendInterface $cache
5562
* @param SerializerInterface $serializer
5663
* @param ProductInterfaceFactory $productFactory
5764
* @param Session $customerSession
5865
*/
5966
public function __construct(
67+
AppState $appState,
6068
MetadataPool $metadataPool,
6169
FrontendInterface $cache,
6270
SerializerInterface $serializer,
6371
ProductInterfaceFactory $productFactory,
6472
Session $customerSession
6573
) {
74+
$this->appState = $appState;
6675
$this->metadataPool = $metadataPool;
6776
$this->cache = $cache;
6877
$this->serializer = $serializer;
@@ -111,6 +120,7 @@ private function getCacheKey($product, $requiredAttributeIds = null): string
111120
$product->getData($metadata->getLinkField()),
112121
$product->getStoreId(),
113122
$this->customerSession->getCustomerGroupId(),
123+
$this->appState->getAreaCode(),
114124
];
115125
if ($requiredAttributeIds !== null) {
116126
sort($requiredAttributeIds);

app/code/Magento/ConfigurableProduct/etc/di.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,15 @@
262262
</argument>
263263
</arguments>
264264
</type>
265-
<type name="Magento\ConfigurableProduct\Model\Plugin\Frontend\UsedProductsCache">
265+
<type name="Magento\ConfigurableProduct\Model\Plugin\UsedProductsCache">
266266
<arguments>
267267
<argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Collection</argument>
268268
</arguments>
269269
<arguments>
270270
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Json</argument>
271271
</arguments>
272272
</type>
273+
<type name="Magento\ConfigurableProduct\Model\Product\Type\Configurable">
274+
<plugin name="used_products_cache" type="Magento\ConfigurableProduct\Model\Plugin\UsedProductsCache" />
275+
</type>
273276
</config>

app/code/Magento/ConfigurableProduct/etc/frontend/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@
1010
<type name="Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface">
1111
<plugin name="Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder" type="Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder"/>
1212
</type>
13-
<type name="Magento\ConfigurableProduct\Model\Product\Type\Configurable">
14-
<plugin name="used_products_cache" type="Magento\ConfigurableProduct\Model\Plugin\Frontend\UsedProductsCache" />
15-
</type>
1613
</config>

0 commit comments

Comments
 (0)