File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
app/code/Magento/CatalogInventory
Test/Unit/Model/Adminhtml/Stock Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 11
11
use Magento \Customer \Api \GroupManagementInterface ;
12
12
use Magento \Framework \Api \AttributeValueFactory ;
13
13
use Magento \Framework \Api \ExtensionAttributesFactory ;
14
+ use Magento \Framework \Object \IdentityInterface ;
15
+ use Magento \Catalog \Model \Product ;
14
16
15
17
/**
16
18
* Catalog Inventory Stock Model for adminhtml area
17
19
* @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes()
18
20
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
19
21
*/
20
- class Item extends \Magento \CatalogInventory \Model \Stock \Item
22
+ class Item extends \Magento \CatalogInventory \Model \Stock \Item implements IdentityInterface
21
23
{
22
24
/**
23
25
* @var GroupManagementInterface
@@ -122,4 +124,17 @@ public function getShowDefaultNotificationMessage()
122
124
{
123
125
return true ;
124
126
}
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
+ }
125
140
}
Original file line number Diff line number Diff line change @@ -58,4 +58,10 @@ public function testGetCustomerGroupId()
58
58
$ this ->_model ->setCustomerGroupId (2 );
59
59
$ this ->assertEquals (2 , $ this ->_model ->getCustomerGroupId ());
60
60
}
61
+
62
+ public function testGetIdentities ()
63
+ {
64
+ $ this ->_model ->setProductId (1 );
65
+ $ this ->assertEquals (['catalog_product_1 ' ], $ this ->_model ->getIdentities ());
66
+ }
61
67
}
You can’t perform that action at this time.
0 commit comments