Skip to content

Commit 8ff2e8a

Browse files
author
Leonid Poluyanov
committed
Merge remote-tracking branch 'origin/MAGETWO-37730' into develop
2 parents d29e3ea + fd332ed commit 8ff2e8a

File tree

2 files changed

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

2 files changed

+22
-1
lines changed

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

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

1517
/**
1618
* Catalog Inventory Stock Model for adminhtml area
1719
* @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes()
1820
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1921
*/
20-
class Item extends \Magento\CatalogInventory\Model\Stock\Item
22+
class Item extends \Magento\CatalogInventory\Model\Stock\Item implements IdentityInterface
2123
{
2224
/**
2325
* @var GroupManagementInterface
@@ -122,4 +124,17 @@ public function getShowDefaultNotificationMessage()
122124
{
123125
return true;
124126
}
127+
128+
/**
129+
* @inheritdoc
130+
*/
131+
public function getIdentities()
132+
{
133+
$tags = [];
134+
if ($this->getProductId()) {
135+
$tags[] = Product::CACHE_TAG . '_' . $this->getProductId();
136+
}
137+
138+
return $tags;
139+
}
125140
}

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)