Skip to content

Commit 9cbda8c

Browse files
author
Anna Bukatar
committed
ACP2E-443: Configurable product remains out of stock even after full reindex if it's in stock and is_salable is set to 0
- Fixed builds
1 parent e9bd4ae commit 9cbda8c

File tree

5 files changed

+21
-37
lines changed

5 files changed

+21
-37
lines changed

app/code/Magento/Catalog/Api/GetProductTypeByIdInterface.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/code/Magento/Catalog/Model/ResourceModel/GetProductTypeById.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
use Magento\Catalog\Api\Data\ProductInterface;
1010
use Magento\Framework\App\ResourceConnection;
11-
use Magento\Catalog\Api\GetProductTypeByIdInterface;
1211

1312
/**
14-
* @inheritdoc
13+
* Get product type ID by product ID.
14+
*
1515
*/
16-
class GetProductTypeById implements GetProductTypeByIdInterface
16+
class GetProductTypeById
1717
{
1818
/**
1919
* @var ResourceConnection
@@ -30,7 +30,10 @@ public function __construct(
3030
}
3131

3232
/**
33-
* @inheritDoc
33+
* Retrieve product type by its product ID
34+
*
35+
* @param int $productId
36+
* @return string
3437
*/
3538
public function execute(int $productId)
3639
{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@
575575
<preference for="Magento\Catalog\Api\Data\CustomOptionInterface" type="Magento\Catalog\Model\CustomOptions\CustomOption" />
576576
<preference for="Magento\Catalog\Api\Data\ProductOptionInterface" type="Magento\Catalog\Model\ProductOption" />
577577
<preference for="Magento\Catalog\Api\Data\CategoryLinkInterface" type="Magento\Catalog\Model\CategoryLink" />
578-
<preference for="Magento\Catalog\Api\GetProductTypeByIdInterface" type="Magento\Catalog\Model\ResourceModel\GetProductTypeById" />
579578
<virtualType name="Magento\Catalog\Model\ResourceModel\Attribute\Collection" type="Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection">
580579
</virtualType>
581580
<type name="Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend">

app/code/Magento/ConfigurableProduct/Model/Plugin/UpdateStockChangedAuto.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66

77
namespace Magento\ConfigurableProduct\Model\Plugin;
88

9-
use Magento\Catalog\Api\GetProductTypeByIdInterface;
9+
use Magento\Catalog\Model\ResourceModel\GetProductTypeById;
1010
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item as ItemResourceModel;
11-
use Magento\CatalogInventory\Model\Stock\Item as StockItem;
11+
use Magento\Framework\Model\AbstractModel as StockItem;
1212
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1313

1414
class UpdateStockChangedAuto
1515
{
1616
/**
17-
* @var GetProductTypeByIdInterface
17+
* @var GetProductTypeById
1818
*/
1919
protected $getProductTypeById;
2020

2121
/**
2222
* UpdateStockChangedAuto constructor
2323
*
24-
* @param GetProductTypeByIdInterface $getProductTypeById
24+
* @param GetProductTypeById $getProductTypeById
2525
*/
26-
public function __construct(GetProductTypeByIdInterface $getProductTypeById)
26+
public function __construct(GetProductTypeById $getProductTypeById)
2727
{
2828
$this->getProductTypeById = $getProductTypeById;
2929
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/UpdateStockChangedAutoTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
use Magento\CatalogInventory\Model\Stock;
1111
use Magento\ConfigurableProduct\Model\Plugin\UpdateStockChangedAuto;
12-
use Magento\Catalog\Api\GetProductTypeByIdInterface;
12+
use Magento\Catalog\Model\ResourceModel\GetProductTypeById;
1313
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item as ItemResourceModel;
14-
use Magento\CatalogInventory\Model\Stock\Item as StockItem;
14+
use Magento\Framework\Model\AbstractModel as StockItem;
1515
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1616
use PHPUnit\Framework\MockObject\MockObject;
1717
use PHPUnit\Framework\TestCase;
@@ -39,7 +39,9 @@ class UpdateStockChangedAutoTest extends TestCase
3939
*/
4040
protected function setUp(): void
4141
{
42-
$this->getProductTypeByIdMock = $this->getMockForAbstractClass(GetProductTypeByIdInterface::class);
42+
$this->getProductTypeByIdMock = $this->getMockBuilder(GetProductTypeById::class)
43+
->disableOriginalConstructor()
44+
->getMock();
4345
$this->plugin = new UpdateStockChangedAuto($this->getProductTypeByIdMock);
4446
}
4547

@@ -53,7 +55,10 @@ public function testBeforeSaveForInStock()
5355
$itemResourceModel = $this->getMockBuilder(ItemResourceModel::class)
5456
->disableOriginalConstructor()
5557
->getMock();
56-
$stockItem = $this->createMock(StockItem::class);
58+
$stockItem = $this->getMockBuilder(StockItem::class)
59+
->disableOriginalConstructor()
60+
->setMethods(['getIsInStock', 'setStockStatusChangedAuto'])
61+
->getMock();
5762
$stockItem->expects(self::once())
5863
->method('getIsInStock')
5964
->willReturn(Stock::STOCK_IN_STOCK);

0 commit comments

Comments
 (0)