Skip to content

Commit f97191e

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-37730: Cache is not updated when changing stock status using mass action
1 parent 7ad03d2 commit f97191e

File tree

2 files changed

+21
-1
lines changed
  • app/code/Magento/CatalogInventory

2 files changed

+21
-1
lines changed

app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
use Magento\Customer\Api\GroupManagementInterface;
1212
use Magento\Framework\Api\AttributeValueFactory;
1313
use Magento\Framework\Api\ExtensionAttributesFactory;
14+
use Magento\Framework\Object\IdentityInterface;
1415

1516
/**
1617
* Catalog Inventory Stock Model for adminhtml area
1718
* @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes()
1819
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1920
*/
20-
class Item extends \Magento\CatalogInventory\Model\Stock\Item
21+
class Item extends \Magento\CatalogInventory\Model\Stock\Item implements IdentityInterface
2122
{
2223
/**
2324
* @var GroupManagementInterface
@@ -122,4 +123,17 @@ public function getShowDefaultNotificationMessage()
122123
{
123124
return true;
124125
}
126+
127+
/**
128+
* @inheritdoc
129+
*/
130+
public function getIdentities()
131+
{
132+
$tags = [];
133+
if ($this->getProductId()) {
134+
$tags[] = 'catalog_product_' . $this->getProductId();
135+
}
136+
137+
return $tags;
138+
}
125139
}

app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ public function testGetCustomerGroupId()
5858
$this->_model->setCustomerGroupId(2);
5959
$this->assertEquals(2, $this->_model->getCustomerGroupId());
6060
}
61+
62+
public function testGetIdentities()
63+
{
64+
$this->_model->setProductId(1);
65+
$this->assertEquals(['catalog_product_1'], $this->_model->getIdentities());
66+
}
6167
}

0 commit comments

Comments
 (0)